Detalhes do pacote

@mdit-vue/plugin-frontmatter

mdit-vue270kMIT3.0.2

A markdown-it plugin to get markdown frontmatter

markdown-it, markdown-it-plugin, vue, frontmatter

readme (leia-me)

@mdit-vue/plugin-frontmatter

npm license

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-frontmatter

Usage

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: GrayMatterOptions

  • Details:

    Options of gray-matter.

renderExcerpt

  • Type: boolean

  • Default: true

    Render the excerpt with markdown-it or not.

    This option will only take effects when grayMatterOptions.excerpt is enabled (disabled by default) or grayMatterOptions.excerpt_separator is set (undefined by default).

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.0.2 (2025-08-11)

Bug Fixes

  • plugin-title: avoid output types being tree-shaken (6255fd4)

3.0.1 (2025-08-11)

Note: Version bump only for package @mdit-vue/monorepo

3.0.0 (2025-08-11)

Build System

BREAKING CHANGES

  • drop node 18 and migrate to pure ESM packages

2.1.4 (2025-04-10)

Bug Fixes

  • plugin-frontmatter: extract frontmatter in parse step (close #13) (#14) (1192bd2)

2.1.3 (2024-05-13)

Note: Version bump only for package @mdit-vue/monorepo

2.1.2 (2024-04-15)

Bug Fixes

  • sync markdown-it types updates (#9) (f6768b1)

2.1.1 (2024-04-13)

Bug Fixes

  • plugin-component: inline html block tags to make cjs build work (eb1a264)

2.1.0 (2024-04-08)

Features

  • upgrade markdown-it types to v14 (6839be8)

2.0.0 (2023-12-08)

Features

BREAKING CHANGES

  • bump to markdown-it 14

1.0.0 (2023-09-26)

Bug Fixes

  • plugin-toc: remove duplicate itemClass (#7) (7e0f1f0)

BREAKING CHANGES

  • drop support for node 16

0.12.1 (2023-08-24)

Note: Version bump only for package mdit-vue

0.12.0 (2023-02-10)

Features

  • plugin-headers: add shouldAllowNested option (93e004d)
  • plugin-toc: add shouldAllowNested option (close #5) (1f3b867)
  • shared: add shouldAllowNested option for resolveHeadersFromTokens (9363b92)

0.11.2 (2022-12-23)

Bug Fixes

  • shared: avoid resolve headers in nested blocks (ce146bd)

0.11.1 (2022-08-30)

Note: Version bump only for package mdit-vue

0.11.0 (2022-08-25)

Features

  • plugin-sfc: extract all script blocks (8c39df6)

0.10.0 (2022-08-23)

Features

  • plugin-headers: resolve link property for headers (da2954f)
  • types: add link property to header (7461417)

0.9.4 (2022-08-23)

Bug Fixes

  • plugin-component: handle multiline component tags correctly (53724fa)

0.9.3 (2022-08-20)

Bug Fixes

  • plugin-headers: avoid headers being overridden by another rendering (de1030b)
  • plugin-title: avoid title being overridden by another rendering (43cc020)

0.9.2 (2022-08-18)

Bug Fixes

  • plugin-toc: avoid toc being overridden by another rendering (c145c26)

0.9.1 (2022-07-26)

Bug Fixes

  • plugin-sfc: expose MarkdownSfcBlocks type (c2a91de)

0.9.0 (2022-07-26)

Features

  • plugin-sfc: extract SFC blocks as structured data (5a0aa54)

BREAKING CHANGES

  • plugin-sfc: the type of env.sfcBlocks has been changed

0.8.1 (2022-07-22)

Bug Fixes

  • plugin-component: make component tags behave like inline tags in some cases (9db6f9c)

0.8.0 (2022-07-22)

Features

  • plugin-component: add blockTags and inlineTags options (4651422)

0.7.1 (2022-07-20)

Note: Version bump only for package mdit-vue

0.7.0 (2022-07-18)

Features

  • plugin-frontmatter: extract content without frontmatter into env.content (a9d5cef)

0.6.0 (2022-07-11)

Features

  • types: extract types from shared package (5fc56ce)

0.5.0 (2022-07-06)

Features

  • plugin-frontmatter: add frontmatter plugin (bcffc7a)

0.4.0 (2022-07-02)

Features

  • plugin-headers: add headers plugin (636aa9b)
  • plugin-title: add title plugin (662e153)

0.3.1 (2022-06-25)

Bug Fixes

  • plugin-toc: export types (310320e)

0.3.0 (2022-06-25)

Features

  • plugin-toc: add toc plugin (e64cc2c)
  • shared: add html escape and unescape utils (e1103c2)

0.2.0 (2022-06-23)

Features

  • plugin-sfc: add sfc plugin (1eb4e0a)
  • shared: add shared package (9e36bdc)

0.1.1 (2022-06-23)

Bug Fixes

  • plugin-component: add js extension to work with esm (42ccdad)

0.1.0 (2022-06-22)

Features

  • plugin-component: add component plugin (cd2eeaa)