feat: Add config.lang for translation links
This commit is contained in:
parent
6e288b3525
commit
6ee952133d
14
src/main.rs
14
src/main.rs
@ -28,8 +28,9 @@ use crate::fetcher::Fetcher;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use camino::{Utf8Path, Utf8PathBuf};
|
use camino::{Utf8Path, Utf8PathBuf};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
//mod atom_serializer;
|
//mod atom_serializer;
|
||||||
mod feed_store;
|
mod feed_store;
|
||||||
@ -76,10 +77,17 @@ struct Config {
|
|||||||
/// This is a folder in the templates_dir. If an assets directory
|
/// This is a folder in the templates_dir. If an assets directory
|
||||||
/// exists within, the contents will be copied over to the out_dir.
|
/// exists within, the contents will be copied over to the out_dir.
|
||||||
theme: Option<String>,
|
theme: Option<String>,
|
||||||
|
/// List of languages for translations
|
||||||
|
#[serde(default)]
|
||||||
|
lang: Vec<Lang>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_checked_pathbuf(dir: &str) -> Utf8PathBuf {
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
let dir = Utf8PathBuf::from(dir);
|
pub struct Lang {
|
||||||
|
code: String,
|
||||||
|
name: String,
|
||||||
|
link: Url,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn to_checked_pathbuf(dir: &Utf8Path) -> Utf8PathBuf {
|
pub fn to_checked_pathbuf(dir: &Utf8Path) -> Utf8PathBuf {
|
||||||
let m = dir
|
let m = dir
|
||||||
|
@ -20,6 +20,7 @@ pub fn build(config: &Config, feed_store: &mut FeedStore) -> Result<()> {
|
|||||||
let (feeds, entries): (HashMap<String, Feed>, _) = feed_store.collect(config.max_entries);
|
let (feeds, entries): (HashMap<String, Feed>, _) = feed_store.collect(config.max_entries);
|
||||||
context.insert("feeds", &feeds);
|
context.insert("feeds", &feeds);
|
||||||
context.insert("entries", &entries);
|
context.insert("entries", &entries);
|
||||||
|
context.insert("lang", &config.lang);
|
||||||
context.insert("PKG_AUTHORS", env!("CARGO_PKG_AUTHORS"));
|
context.insert("PKG_AUTHORS", env!("CARGO_PKG_AUTHORS"));
|
||||||
context.insert("PKG_HOMEPAGE", env!("CARGO_PKG_HOMEPAGE"));
|
context.insert("PKG_HOMEPAGE", env!("CARGO_PKG_HOMEPAGE"));
|
||||||
context.insert("PKG_NAME", env!("CARGO_PKG_NAME"));
|
context.insert("PKG_NAME", env!("CARGO_PKG_NAME"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user