https://github.com/linrz/markdown-yaml-meta
Extract yaml information in markdown.
https://github.com/linrz/markdown-yaml-meta
markdown markdown-yaml yaml-frontmatter
Last synced: 3 months ago
JSON representation
Extract yaml information in markdown.
- Host: GitHub
- URL: https://github.com/linrz/markdown-yaml-meta
- Owner: linrz
- License: mit
- Created: 2018-04-25T16:32:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T14:35:52.000Z (about 8 years ago)
- Last Synced: 2025-09-07T06:30:09.031Z (9 months ago)
- Topics: markdown, markdown-yaml, yaml-frontmatter
- Language: JavaScript
- Size: 18.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# markdown-yaml-meta
  [](https://codecov.io/gh/linrz/markdown-yaml-meta)
## Usage
```sh
$ npm install markdown-yaml-meta
```
## Examples
```
---
layout: post
title: "Hello World"
date: 2018-04-26 00:00:00
author: "linrz"
tags:
- Node.js
---
# Hello Wrold
> Hello, this is an article based on markdown.
## H2 title
## H3 title
```
```js
const fs = require('fs');
const MetaParser = require('markdown-yaml-meta');
const target = path.resolve(__dirname. './blog.md');
const data = MetaParser(target);
console.log(data);
/*
{
"layout": "post",
"title": "Hello World",
"date": "2018-04-26 00:00:00",
"author": "linrunze"
"tags": "['Node.js']"
}
*/
const dataWithPreview = MetaParser(target, { preview: { length: 10 } });
console.log(dataWithPreview);
/*
{
...
"preview": "#Hello\n He..."
}
*/
const dataWithRawPreview = MetaParser(target, { preview: { length: 10, raw: true } });
console.log(dataWithRawPreview);
/*
{
...
"preview": "Hello Wrol..."
}
*/
const dataWithBody = MetaParser(target, { body: true });
console.log(dataWithBody);
/*
{
...
"body": "# Hello Wrold\n> Hello..."
}
*/
```
## Contributing
PR Welcome.
## License
**markdown-yaml-meta** © [linrz](https://github.com/linrz), Released under the [MIT](./LICENSE) License.