An open API service indexing awesome lists of open source software.

https://github.com/lsongdev/tiny-matter

⚡ super tiny front matter parser just ~20 lines with no dependencies.
https://github.com/lsongdev/tiny-matter

Last synced: 7 months ago
JSON representation

⚡ super tiny front matter parser just ~20 lines with no dependencies.

Awesome Lists containing this project

README

          

## 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:

```yaml
---
title: Hello
slug: home
---

Hello world!


```

Into an object like this:

```js
{
content: '

Hello world!

',
data: {
title: 'Hello',
slug: 'home'
}
}
```

### Install

```sh
npm i tiny-matter --save
```

### Example

```js
// 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.