diff options
| -rw-r--r-- | content/templates/partials/header.hbs | 2 | ||||
| -rw-r--r-- | src/response.rs | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/content/templates/partials/header.hbs b/content/templates/partials/header.hbs index 07c6f2f..56f6fc3 100644 --- a/content/templates/partials/header.hbs +++ b/content/templates/partials/header.hbs @@ -1 +1 @@ -=> https://is1-ssl.mzstatic.com/image/thumb/Music112/v4/27/8b/e1/278be12a-185e-2b65-aa68-7e7e98b140f7/859754679778_cover.jpg/316x316bb.webp
\ No newline at end of file +=> {{{ header_image }}}
\ No newline at end of file diff --git a/src/response.rs b/src/response.rs index c6df182..8a58a68 100644 --- a/src/response.rs +++ b/src/response.rs @@ -25,11 +25,12 @@ static QUOTES: LazyLock<Vec<String>> = LazyLock::new(|| { #[derive(yarte::Template)] #[template(path = "main")] struct Main<'a> { - pub body: &'a str, - pub hits: &'a i32, - pub quote: &'a str, - pub commit: &'a str, - pub mini_commit: &'a str, + pub body: &'a str, + pub hits: &'a i32, + pub quote: &'a str, + pub commit: &'a str, + pub mini_commit: &'a str, + pub header_image: &'a str, } pub fn success( @@ -38,15 +39,16 @@ pub fn success( ) -> Response { Response::success( Main { - body: &body.to_string(), - hits: &crate::route::hits_from(context.url.path()), - quote: { + body: &body.to_string(), + hits: &crate::route::hits_from(context.url.path()), + quote: { use rand::prelude::SliceRandom; "ES.choose(&mut rand::thread_rng()).unwrap().to_string() }, - commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), - mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), + commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), + header_image: &std::env::var("HEADER_IMAGE").unwrap_or_else(|_| "https://is1-ssl.mzstatic.com/image/thumb/Music112/v4/27/8b/e1/278be12a-185e-2b65-aa68-7e7e98b140f7/859754679778_cover.jpg/316x316bb.webp".to_string()), } .to_string(), ) |