fix metadata
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
ci/woodpecker/pr/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-10 21:08:42 +02:00
parent 52df4bd9c3
commit dfa62c8e07
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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,
)