@sphido/frontmatter
v3.0.0
Published
Frontmatter for Sphido - A rocket 🚀 fast, lightweight, static site generator
Downloads
148
Readme
@sphido/frontmatter
Front matter is an optional section of valid YAML that is placed at the top
of a page and is used for maintaining metadata for the page and its contents. @sphido/frontmatter is a page extender
that processes these blocks inside page.content. Using the fastest Node.js YAML
Parser js-yaml.
Install
pnpm add @sphido/frontmatterExample
#!/usr/bin/env node
import { getPages, allPages } from '@sphido/core';
import { dirname, relative } from 'node:path';
import { frontmatter } from '@sphido/frontmatter';
const pages = await getPages({path: 'content'}, frontmatter);
for (const page of allPages(pages)) {
console.log(page)
}How to add front matter block
- Must be first in the file
- Must be valid YAML
- Can be closed between triple-dashed lines
---and---or HTML comments<!-- -->
---
title: Page title
tags: [one, two, other]
---
# Content
Lorem ipsum...or
<!--
title: Page title
tags: [one, two, other]
-->
# Content
Lorem ipsum...