tiny-matter
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

tiny-matter

super tiny front matter parser just ~20 lines with no dependencies. Type definitions included.

What's is ?

Converts a string with front-matter, like this:

---
title: Hello
slug: home
---
<h1>Hello world!</h1>

Into an object like this:

{
  content: '<h1>Hello world!</h1>',
  data: {
    title: 'Hello',
    slug: 'home'
  }
}

Install

~$ npm i tiny-matter --save

Example

// CommonJS
const matter = require('tiny-matter');

// ES6
import matter from 'tiny-matter';

console.log(matter('---\ntitle: Front Matter\n---\nThis is content.'));

License

This project is under MIT license.

Dependents (0)

Package Sidebar

Install

npm i tiny-matter

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

6.67 kB

Total Files

10

Last publish

Collaborators

  • song940