diff --git a/src/html/home.rs b/src/html/home.rs index 34ded98..0b00f6f 100644 --- a/src/html/home.rs +++ b/src/html/home.rs @@ -1,6 +1,6 @@ use hypertext::{html_elements, maud, maud_move, GlobalAttributes, Raw, Renderable}; -use crate::{pipeline::Sack, text::md::parse}; +use crate::{pipeline::Sack, text::md::parse, LinkDate, Linkable}; const INTRO: &str = r#" ## かもし @@ -23,19 +23,6 @@ fn intro() -> impl Renderable { ) } -// fn kanji() -> impl Renderable { -// maud!( -// section .p-card { -// h2 .p-card__heading { -// "Kanji of the Day" -// } -// div { -// // -// } -// } -// ) -// } - fn photo() -> impl Renderable { maud!( section .p-card.home-card-image { @@ -51,6 +38,31 @@ 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 + }; + + maud_move!( + section .p-card { + h2 .p-card__heading { + "Latest" + } + ol .p-card__latest { + @for link in links.iter().take(5) { + li { + a href=(link.link.path.as_str()) { + (&link.link.name) + } + } + } + } + } + ) +} + pub(crate) fn home<'s, 'p, 'html>( sack: &'s Sack, main: impl Renderable + 'p, @@ -68,6 +80,7 @@ where (intro()) // (kanji()) (photo()) + (latest(sack)) } } ); diff --git a/styles/layouts/_home.scss b/styles/layouts/_home.scss index 533b99c..650ac7a 100644 --- a/styles/layouts/_home.scss +++ b/styles/layouts/_home.scss @@ -45,6 +45,14 @@ font-family: var(--serif); font-weight: 500; } + + &__latest { + padding-left: 1em; + a { + text-decoration: none; + color: var(--c-primary); + } + } } .home-card-image {