From 062e5e105aeee87c3464a92ee945848cee3bdf71 Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Mon, 30 Sep 2024 17:09:37 +0200 Subject: [PATCH] wip --- src/html/head.rs | 18 ++++++++++++------ src/html/misc.rs | 22 ++++++++-------------- src/html/wiki.rs | 8 ++++---- src/main.rs | 5 +++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/html/head.rs b/src/html/head.rs index 4b50d57..eb96443 100644 --- a/src/html/head.rs +++ b/src/html/head.rs @@ -22,9 +22,15 @@ where 's: 'r, { let title = format!("{} | kamoshi.org", title); - let css = sack.get_styles("styles").expect("Missing styles"); - let css_r = sack.get_styles("reveal").expect("Missing styles"); - let css_p = sack.get_styles("leaflet").expect("Missing styles"); + let css = sack + .get_styles("styles/styles.scss".into()) + .expect("Missing styles"); + let css_r = sack + .get_styles("styles/reveal/reveal.scss".into()) + .expect("Missing styles"); + let css_p = sack + .get_styles("styles/photos/leaflet.scss".into()) + .expect("Missing styles"); let scripts = match scripts { Some(scripts) => Some(emit_tags_script(sack, scripts)?), @@ -40,9 +46,9 @@ where // link rel="sitemap" href="/sitemap.xml"; - (render_style(css)) - (render_style(css_r)) - (render_style(css_p)) + (render_style(&css)) + (render_style(&css_r)) + (render_style(&css_p)) link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"; link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"; diff --git a/src/html/misc.rs b/src/html/misc.rs index 0f1688c..09b58c5 100644 --- a/src/html/misc.rs +++ b/src/html/misc.rs @@ -78,26 +78,18 @@ impl TreePage { } /// Render the page tree -pub(crate) fn show_page_tree<'a>( - path: &'a Utf8Path, - sack: &'a MySack, - glob: &'a str, -) -> impl Renderable + 'a { +pub(crate) fn show_page_tree<'a>(slug: &'a Utf8Path, sack: &'a MySack) -> impl Renderable + 'a { let tree = sack - .get_content_list::(glob) + .get_content_list::("**/*") .into_iter() .map(|query| Link { path: Utf8Path::new("/").join(query.slug), name: query.meta.title.clone(), desc: None, }); - let tree = TreePage::from_iter(tree); - let parts = { - let mut parts = path.iter().skip(1).collect::>(); - parts.insert(0, "wiki"); - parts - }; + let tree = TreePage::from_iter(tree); + let parts: Vec<_> = slug.iter().collect(); maud_move!( h2 .link-tree__heading { @@ -139,8 +131,10 @@ where } } } - @if key == parts[0] && !next.subs.is_empty() { - (show_page_tree_level(next, &parts[1..])) + @if let Some(part) = parts.first() { + @if key == part && !next.subs.is_empty() { + (show_page_tree_level(next, &parts[1..])) + } } } } diff --git a/src/html/wiki.rs b/src/html/wiki.rs index 0bcfa6a..70b354d 100644 --- a/src/html/wiki.rs +++ b/src/html/wiki.rs @@ -18,18 +18,18 @@ pub fn as_html( meta: &Wiki, parsed: &str, sack: &MySack, - path: &Utf8Path, + slug: &Utf8Path, outline: Outline, bibliography: Bibliography, ) -> String { - wiki(meta, parsed, sack, path, outline, bibliography) + wiki(meta, parsed, sack, slug, outline, bibliography) } fn wiki( matter: &Wiki, parsed: &str, sack: &MySack, - path: &Utf8Path, + slug: &Utf8Path, _: Outline, bibliography: Bibliography, ) -> String { @@ -48,7 +48,7 @@ fn wiki( // Navigation tree section .link-tree { div { - (crate::html::misc::show_page_tree(path, sack, "wiki/**/*.html")) + (crate::html::misc::show_page_tree(slug, sack)) } } } diff --git a/src/main.rs b/src/main.rs index dfc1b5a..446929a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,7 @@ fn main() { Collection::glob_with::("content", "wiki/**/*", ["md"].into()), Collection::glob_with::("content", "projects/flox.md", ["md"].into()), ]) + .add_global_styles(["styles".into()]) .add_scripts(vec![ ("search", "./js/search/dist/search.js"), ("photos", "./js/vanilla/photos.js"), @@ -120,13 +121,13 @@ fn main() { }) // Task: generate wiki .add_task(|sack| { - sack.get_content_list::("wiki/**/*") + sack.get_content_list::("**/*") .into_iter() .map(|query| { let (parsed, outline, bib) = html::wiki::parse_content(query.content, &sack, query.file, None); let out_buff = - html::wiki::as_html(query.meta, &parsed, &sack, query.file, outline, bib); + html::wiki::as_html(query.meta, &parsed, &sack, query.slug, outline, bib); (query.slug.join("index.html"), out_buff) }) .collect()