Socket
Book a DemoInstallSign in
Socket

recma-mdx-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recma-mdx-frontmatter

Recma plugin to add frontmatter data as a property to MDX components

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
7
133.33%
Maintainers
1
Weekly downloads
 
Created
Source

recma-mdx-frontmatter

Recma plugin to add frontmatter data as a property to MDX components.

Compatible with MDX and Next.js. You can use this plugin to render templates based on MDX frontmatter.

Usage

Install the plugin:

npm install recma-mdx-frontmatter

Enable it in your next.config.js:

const withMDX = require("@next/mdx")({
  options: {
    // add it here!
    recmaPlugins: [require("recma-mdx-frontmatter")]
  }
})

const nextConfig = {
  pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
}

module.exports = withMDX(nextConfig)

Create some MDX pages with frontmatter:

---
title: My page title
author: Adam Jones
---

This is an awesome MDX page

Use the .frontmatter property, for example in _app.tsx:

import "../styles/globals.css"
import type { AppProps } from "next/app"

export default function App({ Component, pageProps }: AppProps) {
  return (
    <div className="mdx-content">
      <header>
        <h1>{Component.frontmatter.title}</h1>
        <p>Written by {Component.frontmatter.author}</p>
      </header>
      <Component {...pageProps} />
    </div>
  )
}

Only some of your pages use MDX and want to use different layouts for non-MDX pages? Try recma-mdx-displayname.

Contributing

Pull requests are welcomed on GitHub! To get started:

  • Install Git and Node.js
  • Clone the repository
  • Install dependencies with npm install
  • Run npm run test to run tests
  • Build with npm run build

Releases

Versions follow the semantic versioning spec.

To release:

  • Use npm version <major | minor | patch> to bump the version
  • Run git push --follow-tags to push with tags
  • Wait for GitHub Actions to publish to the NPM registry.

FAQs

Package last updated on 14 Jan 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