fix metadata
This commit is contained in:
parent
52df4bd9c3
commit
dfa62c8e07
1 changed files with 9 additions and 4 deletions
|
@ -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<String>,
|
||||
pub link: Option<String>,
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue