diff --git a/src/html/home.rs b/src/html/home.rs
index d4a8f16..0c39503 100644
--- a/src/html/home.rs
+++ b/src/html/home.rs
@@ -1,9 +1,8 @@
-use std::collections::HashMap;
-
-use hauchiwa::Sack;
+use camino::Utf8Path;
+use hauchiwa::{Link, LinkDate, Sack};
use hypertext::{html_elements, maud, maud_move, GlobalAttributes, Raw, Renderable};
-use crate::text::md::parse;
+use crate::{html::Post, text::md::parse};
const INTRO: &str = r#"
## かもし
@@ -43,9 +42,20 @@ fn photo() -> impl Renderable {
fn latest(sack: &Sack) -> impl Renderable {
let links = {
- let mut links = sack.get_links("**");
- links.sort_by(|a, b| b.date.cmp(&a.date));
- links
+ let mut list = sack
+ .get_meta::("**")
+ .into_iter()
+ .map(|(path, meta)| LinkDate {
+ link: Link {
+ path: Utf8Path::new("/").join(path),
+ name: meta.title.clone(),
+ desc: meta.desc.clone(),
+ },
+ date: meta.date,
+ })
+ .collect::>();
+ list.sort_by(|a, b| b.date.cmp(&a.date));
+ list
};
maud_move!(
@@ -81,5 +91,8 @@ pub(crate) fn home(sack: &Sack, main: &str) -> String {
}
);
- crate::html::page(sack, main, "Home".into(), None).unwrap().render().into()
+ crate::html::page(sack, main, "Home".into(), None)
+ .unwrap()
+ .render()
+ .into()
}
diff --git a/src/main.rs b/src/main.rs
index 44b9081..56d9020 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,8 +2,9 @@ mod html;
mod text;
mod ts;
+use camino::Utf8Path;
use clap::{Parser, ValueEnum};
-use hauchiwa::{Collection, Processor, Website};
+use hauchiwa::{Collection, Link, LinkDate, Processor, Website};
use html::{Post, Slideshow, Wiki};
use hypertext::Renderable;
@@ -89,21 +90,57 @@ fn main() {
|sack| {
crate::html::to_list(
sack,
- sack.get_links("projects/**/*.html"),
+ sack.get_meta::("projects/**/*.html")
+ .into_iter()
+ .map(|(path, meta)| LinkDate {
+ link: Link {
+ path: Utf8Path::new("/").join(path),
+ name: meta.title.clone(),
+ desc: meta.desc.clone(),
+ },
+ date: meta.date,
+ })
+ .collect(),
"Projects".into(),
)
},
"projects/index.html".into(),
)
.add_virtual(
- |sack| crate::html::to_list(sack, sack.get_links("posts/**/*.html"), "Posts".into()),
+ |sack| {
+ crate::html::to_list(
+ sack,
+ sack.get_meta::("posts/**/*.html")
+ .into_iter()
+ .map(|(path, meta)| LinkDate {
+ link: Link {
+ path: Utf8Path::new("/").join(path),
+ name: meta.title.clone(),
+ desc: meta.desc.clone(),
+ },
+ date: meta.date,
+ })
+ .collect(),
+ "Posts".into(),
+ )
+ },
"posts/index.html".into(),
)
.add_virtual(
|sack| {
crate::html::to_list(
sack,
- sack.get_links("slides/**/*.html"),
+ sack.get_meta::("slides/**/*.html")
+ .into_iter()
+ .map(|(path, meta)| LinkDate {
+ link: Link {
+ path: Utf8Path::new("/").join(path),
+ name: meta.title.clone(),
+ desc: meta.desc.clone(),
+ },
+ date: meta.date,
+ })
+ .collect(),
"Slideshows".into(),
)
},