mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(blog::components::check_update) impl consistency_guard, fix handle_create issues
This commit is contained in:
18 files changed
+392
-85
No files matched your search
@@ -7,7 +7,9 @@ use crate::constants::{
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use dirs::home_dir;
|
||||
use markdown::MdFile;
|
||||
use tracing::warn;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn expand_path(path: String) -> String {
|
||||
if path.starts_with('~') {
|
||||
@@ -31,6 +33,13 @@ pub fn expand_path(path: String) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_post_id(post: &MdFile) -> Option<Uuid> {
|
||||
match post.meta["id"].as_str() {
|
||||
Some(id) => Uuid::parse_str(id).ok(),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_post_identifier(path: &Path) -> Option<String> {
|
||||
if let Some(comp) = path.components().nth_back(1) {
|
||||
comp.as_os_str().to_str().map(|s| s.to_string())
|
||||
|
||||
Reference in new issue
Block a user