@sphido/frontmatter

2.0.14 • Public • Published

@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 page extender that process this blocks inside page.content. Using the fastest Node.js YAML Parser js-yaml.

Install

yarn add @sphido/frontmatter

Example

#!/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 ipusm...

or

<!--
title: Page title
tags: [one, two, other]
-->

# Content

Lorem ipusm...

Source codes

@sphido/frontmatter

Readme

Keywords

none

Package Sidebar

Install

npm i @sphido/frontmatter

Weekly Downloads

2

Version

2.0.14

License

MIT

Unpacked Size

3.9 kB

Total Files

4

Last publish

Collaborators

  • ozzyczech