diff options
| author | Fuwn <[email protected]> | 2022-06-14 00:13:52 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-06-14 00:13:52 -0700 |
| commit | d858f180589012aee67e6f62f79d827f3889cf56 (patch) | |
| tree | 338b017ad8514efdeb7e6d39415e9179b9c83259 /src | |
| parent | refactor(cargo.toml): dependency ordering (diff) | |
| download | locus-d858f180589012aee67e6f62f79d827f3889cf56.tar.xz locus-d858f180589012aee67e6f62f79d827f3889cf56.zip | |
feat(remarks): add more structure to remarks
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/remarks.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/modules/remarks.rs b/src/modules/remarks.rs index 83be334..780b72a 100644 --- a/src/modules/remarks.rs +++ b/src/modules/remarks.rs @@ -18,22 +18,43 @@ use std::lazy::SyncLazy; -pub static REMARKS: SyncLazy<Vec<String>> = SyncLazy::new(|| { +use serde::{Deserialize, Serialize}; + +static REMARKS: SyncLazy<Vec<Remark>> = SyncLazy::new(|| { serde_json::from_str(include_str!("../../content/json/remarks.json")).unwrap() }); +#[derive(Serialize, Deserialize)] +struct Remark { + remark: String, + created: String, + edited: Option<String>, +} + pub fn module(router: &mut windmark::Router) { crate::route::track_mount( router, "/remarks", - "Fuwn's remarks", + "Fuwn's thoughts which are too short to be their own blog; but just long \ + enough to be a remark.", Box::new(|context| { crate::success!( format!( - "# REMARKS\n\n{}", + "# Remarks\n\nFuwn's thoughts which are too short to be their own \ + blog; but just long enough to be a remark.\n\n{}", REMARKS .iter() - .map(|r| format!("* {}", r)) + .map(|r| { + format!( + "* \"{}\" {}{}", + r.remark, + r.created, + r.edited.as_ref().map_or_else( + || "".to_string(), + |edited| format!(" Edited {}", edited) + ) + ) + }) .collect::<Vec<String>>() .join("\n") ), |