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.
- Host: GitHub
- URL: https://github.com/lsongdev/tiny-matter
- Owner: lsongdev
- Created: 2021-10-12T05:04:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-31T01:46:45.000Z (almost 4 years ago)
- Last Synced: 2025-09-06T07:52:33.673Z (7 months ago)
- Language: JavaScript
- Homepage: https://npmjs.org/tiny-matter
- Size: 7.81 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.