diff --git a/src/template.rs b/src/template.rs index da99701..f0307c9 100644 --- a/src/template.rs +++ b/src/template.rs @@ -22,7 +22,7 @@ enum FrontMatter<'a> { } impl FrontMatter<'_> { - fn parse(&self) -> Metadata { + fn parse(&self) -> FileMetadata { match self { Self::Yaml(val) => serde_yaml::from_str(val).unwrap_or_default(), Self::Toml(_val) => todo!(), @@ -32,8 +32,13 @@ impl FrontMatter<'_> { } #[derive(Default, Deserialize)] -pub struct Metadata { +pub struct FileMetadata { pub title: Option, + pub link: Option, +} + +pub struct Metadata { + pub info: FileMetadata, pub mermaid: bool, } @@ -65,7 +70,7 @@ pub fn read_md(filename: &str) -> (Metadata, String) { markdown::mdast::Node::Yaml(v) => FrontMatter::Yaml(&v.value).parse(), markdown::mdast::Node::Toml(v) => FrontMatter::Toml(&v.value).parse(), markdown::mdast::Node::MdxjsEsm(v) => FrontMatter::Json(&v.value).parse(), - _ => Metadata::default(), + _ => FileMetadata::default(), }; // Convert to HTML @@ -92,8 +97,8 @@ pub fn read_md(filename: &str) -> (Metadata, String) { ( Metadata { + info: metadata, mermaid: presence_mermaid, - ..metadata }, html, )