front-matter-html
v1.0.0
Published
Parse Front Matter from an HTML comment
Downloads
2
Maintainers
Readme
front-matter-html
Parse Front Matter from an HTML comment
Installation
npm install front-matter-html
Usage
const fm = require('front-matter-html');
const html = `<!--
kittens: true
puppies: true
lizards: false
-->
<!doctype html>
<html>
<!-- ... -->
</html>
`;
const content = fm(html);
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-html
cd front-matter-html
npm install
npm test
License
MIT © Geoff Kimball