website/src/html/wiki.rs

58 lines
1.5 KiB
Rust
Raw Normal View History

2024-04-13 15:26:52 +02:00
use hypertext::{html_elements, maud_move, GlobalAttributes, Renderable};
2024-04-21 23:02:30 +02:00
2024-04-28 00:26:19 +02:00
use crate::gen::Sack;
use crate::html::misc::show_page_tree;
use crate::html::{misc::show_bibliography, page};
use crate::md::Wiki;
use crate::text::md::Outline;
2024-04-21 23:02:30 +02:00
pub fn wiki<'data, 'html, 'sack, T>(
2024-04-21 11:45:19 +02:00
fm: &'data Wiki,
content: T,
2024-04-22 21:45:53 +02:00
_: Outline,
2024-04-21 23:02:30 +02:00
sack: &'sack Sack,
2024-04-28 00:26:19 +02:00
bib: Option<Vec<String>>,
2024-04-21 11:45:19 +02:00
) -> impl Renderable + 'html
2024-04-13 15:26:52 +02:00
where
2024-04-21 23:02:30 +02:00
'sack: 'html,
2024-04-13 15:26:52 +02:00
'data: 'html,
T: Renderable + 'data
{
let main = maud_move!(
main .wiki-main {
// Slide in/out for mobile
input #wiki-aside-shown type="checkbox" hidden;
aside .wiki-aside {
// Slide button
label .wiki-aside__slider for="wiki-aside-shown" {
img .wiki-icon src="/static/svg/double-arrow.svg" width="24" height="24";
}
// Navigation tree
2024-04-21 23:02:30 +02:00
section .link-tree {
div {
2024-04-28 00:26:19 +02:00
(show_page_tree(sack, "wiki/**/*.html"))
2024-04-21 23:02:30 +02:00
}
}
2024-04-13 15:26:52 +02:00
}
article .wiki-article /*class:list={classlist)*/ {
header class="markdown" {
h1 #top { (fm.title.clone()) }
}
section .wiki-article__markdown.markdown {
(content)
}
2024-04-28 00:26:19 +02:00
@if let Some(bib) = bib {
(show_bibliography(bib))
}
2024-04-13 15:26:52 +02:00
}
}
);
2024-05-02 15:26:08 +02:00
page(&fm.title, main, sack.get_file())
2024-04-13 15:26:52 +02:00
}