scim-docs/node_modules/tiny-matter
2024-08-29 12:10:19 +02:00
..
.github/workflows Initial commit 2024-08-29 12:10:19 +02:00
example Initial commit 2024-08-29 12:10:19 +02:00
test Initial commit 2024-08-29 12:10:19 +02:00
.editorconfig Initial commit 2024-08-29 12:10:19 +02:00
.prettierrc Initial commit 2024-08-29 12:10:19 +02:00
index.d.ts Initial commit 2024-08-29 12:10:19 +02:00
index.js Initial commit 2024-08-29 12:10:19 +02:00
package.json Initial commit 2024-08-29 12:10:19 +02:00
README.md Initial commit 2024-08-29 12:10:19 +02:00

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.