From cab6efd92701f53dd41c5dbdf4d14651d78ad8d6 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 16 Jul 2023 17:22:44 -0400 Subject: xedium groundwork Signed-off-by: Xe Iaso --- src/handlers/mod.rs | 1 + src/handlers/tailwind.rs | 22 ++++++++++++++++++++++ src/main.rs | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 src/handlers/tailwind.rs (limited to 'src') diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index dba9275..01811e3 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -18,6 +18,7 @@ pub mod feeds; pub mod gallery; pub mod streams; pub mod talks; +pub mod tailwind; fn weekday_to_name(w: Weekday) -> &'static str { use Weekday::*; diff --git a/src/handlers/tailwind.rs b/src/handlers/tailwind.rs new file mode 100644 index 0000000..621565a --- /dev/null +++ b/src/handlers/tailwind.rs @@ -0,0 +1,22 @@ +use std::sync::Arc; +use axum::response::IntoResponse; +use axum::{Extension, extract::Path}; +use encre_css::Config; +use http::{HeaderMap, header}; +use crate::app::State; +use super::blog; + +#[instrument(skip(state, headers))] +pub async fn post_view( + Path(name): Path, + Extension(state): Extension>, + headers: HeaderMap, +) -> impl IntoResponse { + let mut config = Config::default(); + + encre_css_typography::register(&mut config); + + let (_code, body) = blog::post_view(Path(name), Extension(state), headers).await.unwrap(); + + ([(header::CONTENT_TYPE, "text/css")], encre_css::generate([body.0.as_str()], &config)) +} diff --git a/src/main.rs b/src/main.rs index 90f8fba..dbb7ab6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,6 +169,8 @@ async fn main() -> Result<()> { .route("/talks/:name", get(handlers::talks::post_view)) // junk google wants .route("/sitemap.xml", get(handlers::feeds::sitemap)) + // tailwind for Xedium + .route("/.within/css/blog/:name", get(handlers::tailwind::post_view)) // static files .nest_service("/static", files) .fallback(handlers::not_found) -- cgit v1.2.3