- Notifications
You must be signed in to change notification settings - Fork1
Markdown files utils for react-static
License
NotificationsYou must be signed in to change notification settings
tb/react-static-markdown
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Markdown files utils forreact-static
yarn add -D globby gray-matter mdxc mdx-loaderyarn add react react-static-markdown
static.config.js
webpack: (config, {defaultLoaders, stage}) => { config.resolve.extensions.push('.md'); config.module.rules = [ { oneOf: [ { test: /\.md$/, use: ['mdx-loader'], }, defaultLoaders.cssLoader, defaultLoaders.jsLoader, defaultLoaders.fileLoader, ], }, ]; return config;},
Usage
import About from 'content/pages/about.md';...<About />
Markdown is transformed to mdx js code string duringgetRoutes
and then evaluated to component.
static.config.js
const getFiles = require('react-static-mdx/getFilesWithMdx');...const pages = await getFiles('content/pages/*.md');
Usage
import mdxToComponent from 'react-static-mdx/mdxToComponent';...const Page = mdxToComponent(page.contentmdx);...<Page {...props} />
React Static uses the MIT license. For more information on this license,click here.