mdzk-rs / mdzk

General-purpose interface to connected notes

Home Page:https://mdzk.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Additional metadata in front matter

MatteoJoliveau opened this issue · comments

Hi there! I'm starting to prototype a wiki SSG (inspired by MediaWiki/Wikipedia but completely statically generated) and mdzk seems like the perfect tool to do content linking and preprocessing! So if it's ok with you I'd like to contribute some features and improvements to mdzk, starting with this one.

Currently only 3 front matter entries are parsed by mdzk: title, tags and date. However, an author might want to add additional metadata that are SSG specific and unrelated to mdzk. For example, my use case will need categories, summary, stub and a few others. A small change to mdzk will allow to collect these additional entries into a single metadata map that can be referenced by downstream tools.

#[derive(Deserialize)]
struct FrontMatter {
    title: Option<String>,
    tags: Option<Vec<String>>,
    date: Option<String>,
+   #[serde(flatten)]
+   metadata: serde_json::Value,
}

If it's ok with you I'll submit a PR

I love to hear that! Really excited to see your project evolve, and I hope mdzk will be of help.

That solution seems perfect, so you can go ahead and submit a PR and I'll have a closer look at it 😄

Also, I'm guessing you want mdzk 1.0.0 to be published ASAP, so that you can use it as a dependency in your project? I've been pretty inactive on this project lately (because of the summer holiday), but we're pretty much ready for release, so I'll keep you posted on when it gets published 👍

Great! I'll open the PR then 😄

Don't worry about publishing, take all the time you need. I'm currently pulling the crate in via Git so I'm in no rush for a stable dependency. My project is still in its prototyping phase, and I can absolutely live with a mainline dependency for now.