@yuheiy/html-frontmatter

Parse front-matter from raw HTML.

Usage no npm install needed!

<script type="module">
  import yuheiyHtmlFrontmatter from 'https://cdn.skypack.dev/@yuheiy/html-frontmatter';
</script>

README

html-frontmatter

Parse front-matter from raw HTML.

Installation

npm install @yuheiy/html-frontmatter

Usage

const parseFrontMatter = require('@yuheiy/html-frontmatter')

const frontMatter = parseFrontMatter(`<!--
title: Awesome article
authors:
  - sato
  - suzuki
  - takahashi
-->

<p>hello</p>
`)

console.log(frontMatter)
/*
{
  data: {
    title: 'Awesome article',
    authors: [
      'sato',
      'suzuki',
      'takahashi'
    ]
  },
  content: '<p>hello</p>\n'
}
*/

License

MIT