use askama::Template; use axum::{extract::State, response::Html}; use crate::{ Result, config::Config, models::{Bookmarks, Section}, }; #[derive(Template)] #[template(path = "index.html")] pub struct MyTemplate { bookmarks: Vec
, } pub async fn handler(State(config): State) -> Result> { let bookmarks = std::fs::read_to_string(config.bookmarks_file)?; let bookmarks: Bookmarks = serde_json::from_str(&bookmarks)?; let template = MyTemplate { bookmarks: bookmarks.sections, }; let html = template.render()?; Ok(Html(html)) }