Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
gatsby-plugin-mdx-frontmatter
Advanced tools
Utility to parse Markdown frontmatter with MDX in Gatsby using GraphQL Schema customization
Utility to parse Markdown frontmatter with MDX in Gatsby using GraphQL Schema customization
This package encompasses the work shared in this blog post.
yarn add gatsby-plugin-mdx-frontmatter
Add following to your gatsby-config.js
:
plugins: [
{
resolve: 'gatsby-plugin-mdx-frontmatter'
},
...
]
Example markdown file we want to attach MDX to:
---
title: My article
items:
- value: >-
Item 1 **value**
- value: >-
Item 2
<Button>React-powered button</Button>
- value: >-
Item 3 __value__
content: >-
Here's a **cool** graph!
<Graph />
---
Article content.
We can use the provided mdx
resolver to attach to each field in your gatsby-node.js
:
exports.createSchemaCustomization = ({ actions: { createTypes } }) => {
createTypes(`
type Mdx implements Node {
frontmatter: MdxFrontmatter
}
type MdxFrontmatter {
items: [ItemValues]
content: String @mdx
}
type ItemValues {
value: String @mdx
}
`);
};
You can then use <MDXProvider />
and <MDXRenderer />
as normal for these fields:
import { MDXProvider } from "@mdx-js/react";
import { MDXRenderer } from "gatsby-plugin-mdx";
import Button from "../components/Button";
import Graph from "../components/Graph";
const Article = ({ frontmatter, body }) => (
<MDXProvider components={{Button, Graph}}>
<div>
<h1>{frontmatter.title}</h1>
<ul>
{frontmatter.items.map((item) => (
<li key={item.value}>
<MDXRenderer>{item.value}</MDXRenderer>
</li>
))}
</ul>
<MDXRenderer>{frontmatter.content}</MDXRenderer>
<MDXRenderer>{body}</MDXRenderer>
</div>
</MDXProvider>
);
FAQs
Utility to parse Markdown frontmatter with MDX in Gatsby using GraphQL Schema customization
The npm package gatsby-plugin-mdx-frontmatter receives a total of 64 weekly downloads. As such, gatsby-plugin-mdx-frontmatter popularity was classified as not popular.
We found that gatsby-plugin-mdx-frontmatter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.