![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@md-plugins/md-plugin-frontmatter
Advanced tools
A markdown-it plugin for handling frontmatter in markdown files.
A Markdown-It plugin that extracts and processes frontmatter from Markdown content. Frontmatter is commonly used for metadata such as titles, authors, and dates, making this plugin essential for static site generators, documentation tools, and content management systems.
gray-matter
library.frontmatter
property of the Markdown-It environment (env
).Install the plugin via your preferred package manager:
# with pnpm:
pnpm add @md-plugins/md-plugin-frontmatter
# with Yarn:
yarn add @md-plugins/md-plugin-frontmatter
# with npm:
npm install @md-plugins/md-plugin-frontmatter
import MarkdownIt from 'markdown-it';
import { frontmatterPlugin } from '@md-plugins/md-plugin-frontmatter';
import type { MarkdownItEnv } from '@md-plugins/shared';
const md = new MarkdownIt();
md.use(frontmatterPlugin, {
renderExcerpt: true,
});
const markdownContent = `
---
title: Frontmatter Example
author: Jane Doe
date: 2024-01-01
---
# Main Content
This is the main content of the Markdown file.
`;
const env: MarkdownItEnv = {};
const renderedOutput = md.render(markdownContent, env);
console.log('Rendered Output:', renderedOutput);
console.log('Extracted Frontmatter:', env.frontmatter);
console.log('Extracted Excerpt:', env.excerpt);
For the example above, the env
will contain:
{
"frontmatter": {
"title": "Frontmatter Example",
"author": "Jane Doe",
"date": "2024-01-01"
},
"excerpt": "<p>This is the main content of the Markdown file.</p>"
}
The md-plugin-frontmatter
plugin supports the following options:
Option | Type | Default | Description |
---|---|---|---|
grayMatterOptions | object | {} | Options for the gray-matter library. Refer to the gray-matter documentation. |
renderExcerpt | boolean | false | Whether to render the excerpt as HTML. If false, the raw Markdown is extracted as the excerpt. |
You can customize the behavior of the gray-matter
library by passing grayMatterOptions
:
md.use(frontmatterPlugin, {
grayMatterOptions: {
delimiters: '+++', // Use "+++" as the frontmatter delimiter
},
})
Run the unit tests with Vitest
to ensure the plugin behaves as expected:
pnpm test
In case this README falls out of date, please refer to the documentation for the latest information.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A markdown-it plugin for handling frontmatter in markdown files.
The npm package @md-plugins/md-plugin-frontmatter receives a total of 120 weekly downloads. As such, @md-plugins/md-plugin-frontmatter popularity was classified as not popular.
We found that @md-plugins/md-plugin-frontmatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.