@@ -38,21 +38,19 @@ MDX seeks to make writing with Markdown and JSX simpler while being more express
3838 - [ Gatsby remark plugins] ( #gatsby-remark-plugins )
3939 - [ Remark plugins] ( #remark-plugins )
4040 - [ Rehype plugins] ( #rehype-plugins )
41- - [ Media types] ( #media-types )
42- - [ Explanation] ( #explanation )
43- - [ shouldBlockNodeFromTransformation] ( #shouldblocknodefromtransformation )
4441 - [ Components] ( #components )
4542 - [ MDXProvider] ( #mdxprovider )
4643 - [ Related] ( #related )
47- - [ MDXRenderer] ( #mdxrenderer )
44+ - [ Troubleshooting] ( #troubleshooting )
45+ - [ Excerpts for non-latin languages] ( #excerpts-for-non-latin-languages )
4846 - [ License] ( #license )
4947
5048## Installation
5149
5250Install:
5351
5452``` shell
55- npm install gatsby-plugin-mdx @mdx-js/mdx@v1 @mdx-js/ react@v1
53+ npm install gatsby-plugin-mdx @mdx-js/react
5654```
5755
5856## Usage
@@ -113,16 +111,13 @@ module.exports = {
113111any other Gatsby plugin. You can define MDX extensions, layouts, global
114112scope, and more.
115113
116- | Key | Default | Description |
117- | ------------------------------------------------------------------------- | -------------------------------------- | --------------------------------------------------------------------- |
118- | [ ` extensions ` ] ( #extensions ) | ` [".mdx"] ` | Configure the file extensions that gatsby-plugin-mdx will process |
119- | [ ` defaultLayouts ` ] ( #default-layouts ) | ` {} ` | Set the layout components for MDX source types |
120- | [ ` gatsbyRemarkPlugins ` ] ( #gatsby-remark-plugins ) | ` [] ` | Use Gatsby-specific remark plugins |
121- | [ ` remarkPlugins ` ] ( #remark-plugins ) | ` [] ` | Specify remark plugins |
122- | [ ` rehypePlugins ` ] ( #rehype-plugins ) | ` [] ` | Specify rehype plugins |
123- | [ ` mediaTypes ` ] ( #media-types ) | ` ["text/markdown", "text/x-markdown"] ` | Determine which media types are processed by MDX |
124- | [ ` shouldBlockNodeFromTransformation ` ] ( #shouldblocknodefromtransformation ) | ` (node) => false ` | Disable MDX transformation for nodes where this function returns true |
125- | [ ` commonmark ` ] ( #commonmark ) | ` false ` | Use CommonMark |
114+ | Key | Default | Description |
115+ | ----------------------------------------------- | ---------- | ----------------------------------------------------------------- |
116+ | [ ` extensions ` ] ( #extensions ) | ` [".mdx"] ` | Configure the file extensions that gatsby-plugin-mdx will process |
117+ | [ ` defaultLayouts ` ] ( #default-layouts ) | ` {} ` | Set the layout components for MDX source types |
118+ | [ ` gatsbyRemarkPlugins ` ] ( #gatsby-remark-plugins ) | ` [] ` | Use Gatsby-specific remark plugins |
119+ | [ ` remarkPlugins ` ] ( #remark-plugins ) | ` [] ` | Specify remark plugins |
120+ | [ ` rehypePlugins ` ] ( #rehype-plugins ) | ` [] ` | Specify rehype plugins |
126121
127122#### Extensions
128123
@@ -411,61 +406,6 @@ module.exports = {
411406}
412407```
413408
414- #### Media types
415-
416- Deciding what content gets processed by ` gatsby-plugin-mdx ` . This is an
417- advanced option that is useful for dealing with specialized generated
418- content. It is not intended to be configured for most users.
419-
420- ``` js
421- // gatsby-config.js
422- module .exports = {
423- plugins: [
424- {
425- resolve: ` gatsby-plugin-mdx` ,
426- options: {
427- mediaTypes: [` text/markdown` , ` text/x-markdown` ],
428- },
429- },
430- ],
431- }
432- ```
433-
434- ##### Explanation
435-
436- Gatsby includes the media-type of the content on any given node. For
437- ` file ` nodes, we choose whether to process the content with MDX or not
438- by the file extension. For remote content or generated content, we
439- choose which nodes to process by looking at the media type.
440-
441- #### shouldBlockNodeFromTransformation
442-
443- Given a function ` (node) => Boolean ` allows you to decide for each node if it should be transformed or not.
444-
445- ``` js
446- // gatsby-config.js
447- module .exports = {
448- plugins: [
449- {
450- resolve: ` gatsby-plugin-mdx` ,
451- options: {
452- shouldBlockNodeFromTransformation (node ) {
453- return (
454- [` NPMPackage` , ` NPMPackageReadme` ].includes (node .internal .type ) ||
455- (node .internal .type === ` File` &&
456- path .parse (node .dir ).dir .endsWith (` packages` ))
457- )
458- },
459- },
460- },
461- ],
462- }
463- ```
464-
465- #### CommonMark
466-
467- MDX will be parsed using CommonMark.
468-
469409### Components
470410
471411MDX and ` gatsby-plugin-mdx ` use components for different things like rendering
@@ -541,41 +481,7 @@ You can also expose any custom component to every mdx file using
541481
542482##### Related
543483
544- - [ MDX components] ( https://mdxjs.com/getting-started/#mdxprovider )
545-
546- #### MDXRenderer
547-
548- ` MDXRenderer ` is a React component that takes _ compiled_ MDX content and
549- renders it. You will need to use this if your MDX content is coming
550- from a GraphQL page query or ` StaticQuery ` .
551-
552- ` MDXRenderer ` takes any prop and passes it on to your MDX content,
553- just like a normal React component.
554-
555- ``` jsx
556- < MDXRenderer title= " My Stuff!" > {mdx .body }< / MDXRenderer>
557- ```
558-
559- Using a page query:
560-
561- ``` jsx
562- import { MDXRenderer } from " gatsby-plugin-mdx"
563-
564- export default class MyPageLayout {
565- render () {
566- return < MDXRenderer> {this .props .data .mdx .body }< / MDXRenderer>
567- }
568- }
569-
570- export const pageQuery = graphql`
571- query MDXQuery($id: String!) {
572- mdx(id: { eq: $id }) {
573- id
574- body
575- }
576- }
577- `
578- ```
484+ - [ React context for MDX] ( https://mdxjs.com/packages/react/#use )
579485
580486## Troubleshooting
581487
0 commit comments