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 camino::{Utf8Path, Utf8PathBuf};
|
||||
use clap::Parser;
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use url::Url;
|
||||
|
||||
//mod atom_serializer;
|
||||
mod feed_store;
|
||||
@ -76,10 +77,17 @@ struct Config {
|
||||
/// This is a folder in the templates_dir. If an assets directory
|
||||
/// exists within, the contents will be copied over to the out_dir.
|
||||
theme: Option<String>,
|
||||
/// List of languages for translations
|
||||
#[serde(default)]
|
||||
lang: Vec<Lang>,
|
||||
}
|
||||
|
||||
pub fn to_checked_pathbuf(dir: &str) -> Utf8PathBuf {
|
||||
let dir = Utf8PathBuf::from(dir);
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Lang {
|
||||
code: String,
|
||||
name: String,
|
||||
link: Url,
|
||||
}
|
||||
|
||||
pub fn to_checked_pathbuf(dir: &Utf8Path) -> Utf8PathBuf {
|
||||
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);
|
||||
context.insert("feeds", &feeds);
|
||||
context.insert("entries", &entries);
|
||||
context.insert("lang", &config.lang);
|
||||
context.insert("PKG_AUTHORS", env!("CARGO_PKG_AUTHORS"));
|
||||
context.insert("PKG_HOMEPAGE", env!("CARGO_PKG_HOMEPAGE"));
|
||||
context.insert("PKG_NAME", env!("CARGO_PKG_NAME"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user