We consider existing frontmatter implementations Not backward compatable with basic Markdown. Primarily due to the fact that they are rendered at all (and badly) by renderers that do not support frontmatter. Therefor we define frontmatter as HTML Comments with a data
prefix.
<!-- data
title: foo
-->
export const viewer = ({ node, React, file }) => {
const matter = file.data.frontmatter;
const keys = Object.keys(matter);
const styles = {
root: {},
item: {
display: "block",
marginRight: "0.4em",
},
bold: { fontWeight: "bold" },
};
const Item = ({ id }) => (
<span key={id} style={styles.item}>
<span style={{ ...styles.bold }}>{id}</span>: <span>{matter[id]}</span>
</span>
);
return (
<div style={styles.root}>
{keys.map((key) => (
<Item id={key} />
))}
</div>
);
};
Currently only the following are actually processed by .lit
- title
- private — See testing/Private Files
- theme — See meta/Styling and Themes
TBD:
- created at & updated at — these should be auto populated from actual file metadata
- author
- read only — prevent updates from having an effect, question is how to disable once set?
- config/includes — more general purpose to compliment config and themes
- backlinks — allow disabling backlinks display
- tags
- aka — alias’ for a document (useful? for backlink coalescing)
return lit.file.data.frontmatter;