front-matter-html
Parse Front Matter from an HTML comment
Installation
npm install front-matter-html
Usage
const fm = ; const html = `<!--kittens: truepuppies: truelizards: false--> <!doctype html><html> <!-- ... --></html>`; const content = ;
API
fm(html)
Parse YAML Front Matter from an HTML comment at the top of an HTML document.
- html (String): input HTML.
Returns an object with these properties:
- attributes (Object): extracted YAML.
- body (String): HTML without Front Matter comment.
- frontmatter (String): original YAML string.
fm.test(html)
Test if an HTML document contains a Front Matter block within <!-- -->
.
Returns true
or false
.
Local Development
git clone https://github.com/gakimball/front-matter-htmlcd front-matter-htmlnpm installnpm test
License
MIT © Geoff Kimball