diff options
| author | Fuwn <[email protected]> | 2024-11-03 23:14:38 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-11-03 23:14:38 -0800 |
| commit | f8fabd790748925e8d27ad3408a147b7edd531f4 (patch) | |
| tree | 81c4cec2fbf3c6bc58bde6695da845f43b976b46 /src/modules/index.rs | |
| parent | feat(blog): priority field (diff) | |
| download | locus-f8fabd790748925e8d27ad3408a147b7edd531f4.tar.xz locus-f8fabd790748925e8d27ad3408a147b7edd531f4.zip | |
feat(index): add recent posts section
Diffstat (limited to 'src/modules/index.rs')
| -rw-r--r-- | src/modules/index.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/modules/index.rs b/src/modules/index.rs new file mode 100644 index 0000000..46ffc74 --- /dev/null +++ b/src/modules/index.rs @@ -0,0 +1,55 @@ +use super::blog::POSTS; + +pub fn module(router: &mut windmark::router::Router) { + crate::route::track_mount( + router, + "/", + "This Gemini capsule's homepage", + move |context| { + crate::response::success( + &format!( + r#"# Fuwn[.me] + +I enjoy writing for archaic systems in dated languages and with artificially imposed constraints, all while aiming for peak performance and minimal design. + +=> https://github.com/Fuwn Projects (GitHub) + +## Recent Posts + +{} + +## More + +I write a lot of software and tooling for the Gemini protocol, the backbone of this site. You can learn more over at GemRest. + +=> https://github.com/gemrest GemRest (GitHub) + +Don't know where to start? Check out the directory or test your luck! + +=> /directory Directory +=> /random I'm Feeling Lucky"#, + { + (*POSTS).lock().map_or_else( + |_| "...".to_string(), + |global_posts| { + let mut posts = global_posts; + + posts.sort_by(|a, b| b.created_at().cmp(a.created_at())); + + posts + .iter() + .map(|post| format!("=> {} {}", post.title(), post.link())) + .collect::<Vec<String>>() + .into_iter() + .take(3) + .collect::<Vec<String>>() + .join("\n") + }, + ) + } + ), + &context, + ) + }, + ); +} |