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 | |
| parent | refactor(cargo.toml): dependency ordering (diff) | |
| download | locus-d858f180589012aee67e6f62f79d827f3889cf56.tar.xz locus-d858f180589012aee67e6f62f79d827f3889cf56.zip | |
feat(remarks): add more structure to remarks
| -rw-r--r-- | content/json/remarks.json | 10 | ||||
| -rw-r--r-- | src/modules/remarks.rs | 29 |
2 files changed, 33 insertions, 6 deletions
diff --git a/content/json/remarks.json b/content/json/remarks.json index 533d564..a01401a 100644 --- a/content/json/remarks.json +++ b/content/json/remarks.json @@ -1,4 +1,10 @@ [ - "Forth users all seem to be part of a cult.", - "COBOL is a great language!" + { + "remark": "Forth users all seem to be part of a cult.", + "created": "2022. 04. 14." + }, + { + "remark": "COBOL is a great language!", + "created": "2022. 04. 14." + } ] 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") ), |