feat: Add config.lang for translation links

This commit is contained in:
selfhoster selfhoster 2025-04-15 13:30:05 +02:00
parent 6e288b3525
commit 6ee952133d
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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"));