feat: latest

This commit is contained in:
Maciej Jur 2024-07-05 14:25:44 +02:00
parent fc01a1ed2a
commit 1c2e87aa25
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
2 changed files with 35 additions and 14 deletions

View file

@ -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 {
// // <Widget client:load/>
// }
// }
// )
// }
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))
}
}
);

View file

@ -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 {