diff --git a/README.md b/README.md index 662790c..67ecac9 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ date_format = "RFC3339" # format string used to format dates in the backend # so the date can be formatted by the browser. # format: https://docs.rs/chrono/latest/chrono/format/strftime/index.html#specifiers js_enable = true # enable javascript (required for above) +default_color = "#f5c2e7" # default embed color, optional [rss] enable = false # serve an rss field under /feed.xml diff --git a/src/app.rs b/src/app.rs index dd31b5f..aa4d38d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -45,6 +45,7 @@ struct PostTemplate { markdown_access: bool, df: DateFormat, js: bool, + color: Option, } #[derive(Deserialize)] @@ -148,6 +149,11 @@ async fn post( ) -> AppResult { match posts.get_post(&name).await? { ReturnedPost::Rendered(meta, rendered, rendered_in) => { + let color = meta + .color + .as_ref() + .or(config.default_color.as_ref()) + .cloned(); let page = PostTemplate { meta, rendered, @@ -155,6 +161,7 @@ async fn post( markdown_access: config.markdown_access, df: config.date_format.clone(), js: config.js_enable, + color, }; Ok(page.into_response()) diff --git a/src/config.rs b/src/config.rs index 0906af9..50bbd8a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -75,6 +75,7 @@ pub struct Config { pub markdown_access: bool, pub date_format: DateFormat, pub js_enable: bool, + pub default_color: Option, pub rss: RssConfig, pub dirs: DirsConfig, pub http: HttpConfig, @@ -90,6 +91,7 @@ impl Default for Config { markdown_access: true, date_format: Default::default(), js_enable: true, + default_color: Some("#f5c2e7".into()), // i have a love-hate relationship with serde // it was engimatic at first, but then i started actually using it // writing my own serialize and deserialize implementations.. spending diff --git a/templates/post.html b/templates/post.html index da6674a..cd05916 100644 --- a/templates/post.html +++ b/templates/post.html @@ -20,7 +20,7 @@ {% when None %} {% endmatch %} - {% match meta.color %} {% when Some with (color) %} + {% match color %} {% when Some with (color) %} {% when None %} {% endmatch %} {{ meta.title }}