summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQrius <[email protected]>2024-09-26 00:11:06 +0200
committerQrius <[email protected]>2024-09-26 00:11:06 +0200
commit281d3a36c03f0827e799070341a995d754f5e32e (patch)
treef1fa2dcaedaa9a7e9a6fe7bbbd9e214902fef0ff
parent4a066c532f86c6ba7d90762afb9ed8ba70c9e55b (diff)
downloadskaldpress-281d3a36c03f0827e799070341a995d754f5e32e.tar.gz
skaldpress-281d3a36c03f0827e799070341a995d754f5e32e.zip
Move change_date override to metadata parser
-rw-r--r--src/skaldpress/main.rs7
-rw-r--r--src/skaldpress/metadata_parser.rs8
2 files changed, 7 insertions, 8 deletions
diff --git a/src/skaldpress/main.rs b/src/skaldpress/main.rs
index bd0ebd3..574bc6a 100644
--- a/src/skaldpress/main.rs
+++ b/src/skaldpress/main.rs
@@ -187,13 +187,6 @@ fn macro_processor_initialize(
macro_processor.define_macro(key.to_string(), value.clone());
}
}
-
- if let Some(publish_date) = metadata.get("publish_date") {
- if !metadata.contains_key("change_date") {
- macro_processor
- .define_macro_string(format!("METADATA_change_date"), publish_date.to_string());
- }
- }
}
fn get_template_path(template: &str, opts: &Opts) -> String {
diff --git a/src/skaldpress/metadata_parser.rs b/src/skaldpress/metadata_parser.rs
index a2abcc2..66a96b6 100644
--- a/src/skaldpress/metadata_parser.rs
+++ b/src/skaldpress/metadata_parser.rs
@@ -4,7 +4,7 @@ use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt;
-#[derive(Eq, PartialEq, Debug)]
+#[derive(Clone, Eq, PartialEq, Debug)]
pub enum YamlValue {
Scalar(String),
Integer(i64),
@@ -130,5 +130,11 @@ pub fn extract_parse_yaml_metadata<'a>(
end_index = markdown.len();
}
+ if let Some(publish_date) = yaml_map.get("publish_date") {
+ if !yaml_map.contains_key("change_date") {
+ yaml_map.insert("change_date".to_string(), publish_date.clone());
+ }
+ }
+
Some((yaml_map, &markdown[end_index..]))
}