Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/landakram/remark-parse-yaml
Parse YAML blocks into structured data.
https://github.com/landakram/remark-parse-yaml
remark remark-plugin yaml yaml-frontmatter
Last synced: 3 months ago
JSON representation
Parse YAML blocks into structured data.
- Host: GitHub
- URL: https://github.com/landakram/remark-parse-yaml
- Owner: landakram
- License: mit
- Created: 2017-12-24T19:03:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-28T18:41:36.000Z (over 5 years ago)
- Last Synced: 2024-11-11T18:52:42.621Z (3 months ago)
- Topics: remark, remark-plugin, yaml, yaml-frontmatter
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 14
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remark-parse-yaml
[![npm version](https://badge.fury.io/js/remark-parse-yaml.svg)](https://badge.fury.io/js/remark-parse-yaml) [![Build Status](https://travis-ci.org/landakram/remark-parse-yaml.svg?branch=master)](https://travis-ci.org/landakram/remark-parse-yaml)This [remark](https://github.com/wooorm/remark) plugin takes markdown with yaml frontmatter and parses the yaml into an object.
## Usage
```javascript
const unified = require('unified')
const markdown = require('remark-parse')
const frontmatter = require('remark-frontmatter')
const parseFrontmatter = require('remark-parse-yaml');let processor = unified()
.use(markdown)
.use(frontmatter)
.use(parseFrontmatter)
```When the processor is run, `yaml` nodes will now have an additional key, `parsedValue`,
attached to its `data` key.Say that we have this markdown string:
``` markdown
---
metadata: this is metadata
tags:
- one
- two
---# Heading
```When parsed, this will produce a `yaml` node with a `data` object that looks like this:
```javascript
data: {
parsedValue: {
metadata: "this is metadata",
tags: ["one", "two"]
}
}
```