mdx-yaml-full
Description
A plugin for gatsby-transformer-yaml-full
to parse MDX strings into MDX.
Installation
Run npm install --save mdx-yaml-full
or yarn add mdx-yaml-full
Configuration
// gatsby-config.js moduleexports = plugins: resolve: 'gatsby-transformer-yaml-full' options: plugins: `mdx-yaml-full` // ... ;
Usage
YAML File:
- name: 'Thing' content: !mdx | # Hello world I am MDX! - Much wow - Such **cool**
With the following GraphQL:
{ # Depends on file name allFileYaml { nodes { name content { body } } }}
Results in the following data:
Where content
can be piped into the children
of the MDXRenderer
!
import React from 'react';import useStaticQuery graphql from 'gatsby';import MDXRenderer from 'gatsby-plugin-mdx'; const Example = const data = ; const name content = dataallFileYamlnodes0; return <> <h1>name</h1> <MDXRenderer>contentbody</MDXRenderer> </> ;;
License
This project is licensed using the MIT license.