Markdown Metadata
Markdown metadata extractor. Extract metadata from a markdown document.
Installation
Install the latest version with npm or Yarn:
$ npm install @cmdlucas/markdown-metadata
$ yarn add @cmdlucas/markdown-metadata
Usage
In order to be parsed, metadata must be placed at the beginning of the markdown document between two triple dashes. Example:
---
title: Lorem ipsum dolor sit amet
author: Marcus Antonius
keywords: latin, ipsum
---
Vestibulum tortor quam, *feugiat vitae*, ultricies eget, tempor sit amet, ante.
Here's how to parse the metadata:
const metadataParser = require('@cmdlucas/markdown-metadata');
const source = '--- title: Lorem...';
const result = metadataParser(source);
result.metadata;
result.content;
Parse Support
Currently, only yaml
is supported. Future versions intend to support toml
and other popular file configuration formats.
License
Markdown Metadata extractor is licensed under the MIT License. See the LICENSE
file for details.