Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kricsleo/markdown-it-meta-yaml
Markdown-It plugin for parsing YAML front matter.
https://github.com/kricsleo/markdown-it-meta-yaml
Last synced: 24 days ago
JSON representation
Markdown-It plugin for parsing YAML front matter.
- Host: GitHub
- URL: https://github.com/kricsleo/markdown-it-meta-yaml
- Owner: kricsleo
- License: mit
- Created: 2023-03-25T10:20:28.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-03-25T15:38:32.000Z (over 1 year ago)
- Last Synced: 2024-10-08T12:22:02.407Z (30 days ago)
- Language: TypeScript
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
markdown-it-meta-yaml
Markdown-It plugin for parsing YAML front matter.[![NPM version](https://img.shields.io/npm/v/markdown-it-meta-yaml?color=a1b858&label=)](https://www.npmjs.com/package/markdown-it-meta-yaml)
Parsing YAML-formatted metadata from markdown files and converting it into JSON-formatted data.
🥳 All YAML values are supported - powered by [js-yaml](https://github.com/nodeca/js-yaml)
```markdown
---
title: Hello Markdown
date: 2023-03-25 12:00
score: 1.8
tags:
- frontend
- markdown
---
```👇🏻
```json
{
"title": "Hello Markdown",
"date": "2023-03-25 12:00",
"score": 1.8,
"tags": [
"frontend",
"markdown"
]
}
```## Usage
Use it as a plugin for [markdown-it](https://github.com/markdown-it/markdown-it)
```bash
npm install markdown-it-meta-yaml
``````ts
import MarkdownIt from 'markdown-it'
import markdownItMetaYaml from 'markdown-it-meta-yaml'const markdownIt = new MarkdownIt()
markdownIt.use(markdownItMetaYaml, {
cb: (metaJSON, metaRaw) => console.log(metaJSON, metaRaw)
})// metaJSON =>
// {
// "title": "Hello Markdown",
// "date": "2023-03-25 12:00",
// "score": 1.8,
// "tags": [
// "frontend",
// "markdown"
// ]
// }// metaRaw =>
// title: Hello Markdown
// date: 2023-03-25 12:00
// score: 1.8
// tags:
// - frontend
// - markdown
```## License
[MIT](./LICENSE) License © 2023 [Kricsleo](https://github.com/kricsleo)