feat: latest
This commit is contained in:
parent
fc01a1ed2a
commit
1c2e87aa25
|
@ -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))
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue