2.1.4 • Published 7 months ago
@mdit-vue/plugin-frontmatter v2.1.4
@mdit-vue/plugin-frontmatter
A markdown-it plugin to get markdown frontmatter with gray-matter.
- Extracts frontmatter into markdown-it
env.frontmatter. - Allows providing default frontmatter via markdown-it
env.frontmatter. - Extracts markdown content without frontmatter into markdown-it
env.content. - Supports extracting rendered excerpt into markdown-it
env.excerpt.
Install
npm i @mdit-vue/plugin-frontmatterUsage
import { frontmatterPlugin } from '@mdit-vue/plugin-frontmatter';
import type { MarkdownItEnv } from '@mdit-vue/types';
import MarkdownIt from 'markdown-it';
const md = MarkdownIt({ html: true }).use(frontmatterPlugin, {
// options
grayMatterOptions: {
excerpt: true,
excerpt_separator: '<!-- more -->',
},
});
const env: MarkdownItEnv = {};
const rendered = md.render(
`\
---
title: foobar
---
Everything above **more** comment will be extracted as excerpt.
<!-- more -->
Things below **more** comment will not be included in the excerpt.
`,
env,
);
console.log(env.frontmatter);
console.log(env.content);
console.log(env.excerpt);Options
grayMatterOptions
Type:
GrayMatterOptionsDetails:
Options of gray-matter.
renderExcerpt
Type:
booleanDefault:
trueRender the excerpt with markdown-it or not.
This option will only take effects when
grayMatterOptions.excerptis enabled (disabled by default) orgrayMatterOptions.excerpt_separatoris set (undefined by default).
2.1.4
7 months ago
2.1.3
1 year ago
2.1.2
2 years ago
2.1.0
2 years ago
2.0.0
2 years ago
1.0.0
2 years ago
0.12.1
2 years ago
0.12.0
3 years ago
0.10.0
3 years ago
0.11.0
3 years ago
0.11.1
3 years ago
0.9.2
3 years ago
0.9.1
3 years ago
0.9.0
3 years ago
0.8.0
3 years ago
0.7.1
3 years ago
0.7.0
3 years ago
0.6.0
3 years ago
0.5.0
3 years ago