Socket
Socket
Sign inDemoInstall

@mdit-vue/plugin-frontmatter

Package Overview
Dependencies
19
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mdit-vue/plugin-frontmatter

A markdown-it plugin to get markdown frontmatter


Version published
Maintainers
1
Install size
1.79 MB
Created

Changelog

Source

0.9.2 (2022-08-18)

Bug Fixes

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

Readme

Source

@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 MarkdownIt from 'markdown-it';
import { frontmatterPlugin } from '@mdit-vue/plugin-frontmatter';
import type { MarkdownItEnv } from '@mdit-vue/types';

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).

Keywords

FAQs

Last updated on 18 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc