From d858f180589012aee67e6f62f79d827f3889cf56 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 14 Jun 2022 00:13:52 -0700 Subject: feat(remarks): add more structure to remarks --- src/modules/remarks.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/modules') 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> = SyncLazy::new(|| { +use serde::{Deserialize, Serialize}; + +static REMARKS: SyncLazy> = SyncLazy::new(|| { serde_json::from_str(include_str!("../../content/json/remarks.json")).unwrap() }); +#[derive(Serialize, Deserialize)] +struct Remark { + remark: String, + created: String, + edited: Option, +} + 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::>() .join("\n") ), -- cgit v1.2.3