ref(backend) major refactor

- remove struct Post, use database schema and Map instead
- add sub_title
- replace NaiveDateTime with DateTime<Utc>
This commit is contained in:
lumither committed 2024-05-12 17:00:37 +08:00
1 parent 7d856f25a3
commit fd8b760b7f
9 files changed
+170 -159

No files matched your search

+6 -2
View File
@@ -2,6 +2,7 @@ use std::collections::HashMap;
use regex::Regex;
/// return the meta info contained in the .md file front matter
pub fn parse_meta(md_content: &str) -> HashMap<String, String> {
let mut fields: HashMap<String, String> = HashMap::new();
let match_regex = Regex::new(r"(?s)---\n(.*\n)---\n").unwrap();
@@ -41,11 +42,14 @@ mod meta_test {
title: Hello World!
tags: [ "test", "hello_world" ]
---
"##
"##,
);
dbg!(&parsed_meta);
assert_eq!(parsed_meta.get("title"), Some(&"Hello World!".to_string()));
assert_eq!(parsed_meta.get("tags"), Some(&r#"[ "test", "hello_world" ]"#.to_string()));
assert_eq!(
parsed_meta.get("tags"),
Some(&r#"[ "test", "hello_world" ]"#.to_string())
);
Ok(())
}
}