aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-11-03 19:55:25 -0800
committerFuwn <[email protected]>2024-11-03 19:55:25 -0800
commitfe632058c09a892f23a370f33b992485ed1212f2 (patch)
tree86225584211b305555fa1a5c9008109dea1bc206
parentchore(flake): pin openssl (diff)
downloadlocus-fe632058c09a892f23a370f33b992485ed1212f2.tar.xz
locus-fe632058c09a892f23a370f33b992485ed1212f2.zip
feat(blog): priority field
-rw-r--r--content/blogs/finger_archive/blog.json3
-rw-r--r--content/blogs/news/blog.json3
-rw-r--r--content/blogs/technology/blog.json3
-rw-r--r--content/blogs/the_daily/blog.json3
-rw-r--r--src/modules/blog/config.rs10
-rw-r--r--src/modules/blog/module.rs21
6 files changed, 34 insertions, 9 deletions
diff --git a/content/blogs/finger_archive/blog.json b/content/blogs/finger_archive/blog.json
index a247bcf..2148303 100644
--- a/content/blogs/finger_archive/blog.json
+++ b/content/blogs/finger_archive/blog.json
@@ -1,4 +1,5 @@
{
+ "priority": 2,
"posts": {
"2024_06_27": {
"name": "June 27th, 2024"
@@ -7,4 +8,4 @@
"name": "June 29th, 2024"
}
}
-}
+} \ No newline at end of file
diff --git a/content/blogs/news/blog.json b/content/blogs/news/blog.json
index ddbfbad..181335d 100644
--- a/content/blogs/news/blog.json
+++ b/content/blogs/news/blog.json
@@ -1,4 +1,5 @@
{
+ "priority": 1,
"description": "The [Inconsistently Updated] Update Log of This Gemini Capsule",
"posts": {}
-}
+} \ No newline at end of file
diff --git a/content/blogs/technology/blog.json b/content/blogs/technology/blog.json
index efbfcfe..d58ec59 100644
--- a/content/blogs/technology/blog.json
+++ b/content/blogs/technology/blog.json
@@ -1,4 +1,5 @@
{
+ "priority": 3,
"description": "Thoughts and Resources of the Programming Languages and Technologies I Actively Use and Have Used",
"posts": {
"Go": {
@@ -22,4 +23,4 @@
"last_modified": "2021. 07. 23."
}
}
-}
+} \ No newline at end of file
diff --git a/content/blogs/the_daily/blog.json b/content/blogs/the_daily/blog.json
index 14d39c8..fc7bfb5 100644
--- a/content/blogs/the_daily/blog.json
+++ b/content/blogs/the_daily/blog.json
@@ -1,4 +1,5 @@
{
+ "priority": 0,
"description": null,
"posts": {
"nvme_troubles_part_1": {
@@ -30,4 +31,4 @@
"name": "The AirPods 4 with ANC are impressive!"
}
}
-}
+} \ No newline at end of file
diff --git a/src/modules/blog/config.rs b/src/modules/blog/config.rs
index 20c3bd4..c2e4cc9 100644
--- a/src/modules/blog/config.rs
+++ b/src/modules/blog/config.rs
@@ -1,6 +1,7 @@
-use std::collections::HashMap;
-
-use serde::{Deserialize, Serialize};
+use {
+ serde::{Deserialize, Serialize},
+ std::collections::HashMap,
+};
#[derive(Serialize, Deserialize, Clone, Default)]
pub struct Entry {
@@ -27,6 +28,7 @@ pub struct Blog {
name: Option<String>,
description: Option<String>,
posts: Option<HashMap<String, Entry>>,
+ priority: Option<u8>,
}
impl Blog {
pub const fn description(&self) -> &Option<String> { &self.description }
@@ -35,6 +37,8 @@ impl Blog {
pub const fn posts(&self) -> &Option<HashMap<String, Entry>> { &self.posts }
+ pub const fn priority(&self) -> &Option<u8> { &self.priority }
+
pub fn from_string(string: &str) -> serde_json::Result<Self> {
serde_json::from_str(string)
}
diff --git a/src/modules/blog/module.rs b/src/modules/blog/module.rs
index e6fcd06..bfab002 100644
--- a/src/modules/blog/module.rs
+++ b/src/modules/blog/module.rs
@@ -80,7 +80,24 @@ pub fn module(router: &mut windmark::router::Router) {
);
}
- let blog_clone = blogs.clone();
+ let mut blog_clone: Vec<_> = blogs
+ .clone()
+ .into_iter()
+ .map(|(blog, entries)| {
+ (
+ blog,
+ *entries
+ .get("blog.json")
+ .and_then(|content| Blog::from_string(content).ok())
+ .unwrap_or_default()
+ .priority(),
+ entries,
+ )
+ })
+ .collect();
+
+ blog_clone.sort_by(|a, b| b.1.cmp(&a.1));
+ blog_clone.reverse();
track_mount(router, "/blog", "Fuwn's blogs", move |context| {
success(
@@ -89,7 +106,7 @@ pub fn module(router: &mut windmark::router::Router) {
blog_clone.len(),
blog_clone
.iter()
- .map(|(title, entries)| (title.clone(), entries.clone()))
+ .map(|(title, _, entries)| (title.clone(), entries.clone()))
.collect::<Vec<(_, _)>>()
.into_iter()
.map(|(title, entries)| {