aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/tailwind.rs
blob: 621565a997deebfff1ae607f5ef5f0fc8b330a27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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<String>,
    Extension(state): Extension<Arc<State>>,
    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))
}