Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-mdx-frontmatter

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-mdx-frontmatter

A remark plugin for converting frontmatter metadata into MDX exports

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
340K
decreased by-32.96%
Maintainers
0
Weekly downloads
 
Created

What is remark-mdx-frontmatter?

The remark-mdx-frontmatter package is a plugin for the remark processor that allows you to parse and transform frontmatter in MDX files. This is useful for handling metadata in your MDX content, such as titles, dates, and other custom fields.

What are remark-mdx-frontmatter's main functionalities?

Parsing Frontmatter

This feature allows you to parse frontmatter in MDX files. The code sample demonstrates how to use the remark-mdx-frontmatter plugin to parse frontmatter and process the MDX content.

const remark = require('remark');
const mdx = require('remark-mdx');
const frontmatter = require('remark-mdx-frontmatter');

const content = `---
title: 'Hello World'
date: '2023-10-01'
---

# Hello World`;

remark()
  .use(mdx)
  .use(frontmatter)
  .process(content, (err, file) => {
    if (err) throw err;
    console.log(String(file));
  });

Transforming Frontmatter

This feature allows you to transform frontmatter in MDX files. The code sample demonstrates how to use a custom transformer to manipulate the frontmatter data after it has been parsed.

const remark = require('remark');
const mdx = require('remark-mdx');
const frontmatter = require('remark-mdx-frontmatter');

const content = `---
title: 'Hello World'
date: '2023-10-01'
---

# Hello World`;

const transformer = () => (tree) => {
  // Transform the frontmatter here
  console.log(tree.children[0].data);
};

remark()
  .use(mdx)
  .use(frontmatter)
  .use(transformer)
  .process(content, (err, file) => {
    if (err) throw err;
    console.log(String(file));
  });

Other packages similar to remark-mdx-frontmatter

Keywords

FAQs

Package last updated on 21 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc