Skip to content

Commit

Permalink
clean up dependencies and restore changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed May 13, 2022
1 parent 5e49e0f commit e0b26c8
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 609 deletions.
4 changes: 2 additions & 2 deletions benchmarks/gabe-fs-mdx/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ module.exports = {
},
},
},
`gatsby-plugin-webpack-bundle-analyser-v2`,
],
!process.env.CI && `gatsby-plugin-webpack-bundle-analyser-v2`,
].filter(Boolean),
}
13 changes: 6 additions & 7 deletions benchmarks/gabe-fs-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
"mdx"
],
"dependencies": {
"@mdx-js/mdx": "^1",
"@mdx-js/react": "^1",
"@mdx-js/react": "^2",
"faker": "^4.1.0",
"gatsby": "^2",
"gatsby-plugin-mdx": "^1",
"gatsby-source-filesystem": "^2",
"react": "^16.12.0",
"react-dom": "^16.12.0"
"gatsby": "^4",
"gatsby-plugin-mdx": "^3",
"gatsby-source-filesystem": "^4",
"react": "^17",
"react-dom": "^17"
}
}
4 changes: 2 additions & 2 deletions e2e-tests/mdx/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ module.exports = {
remarkPlugins: [remarkRequireFilePathPlugin],
},
},
`gatsby-plugin-webpack-bundle-analyser-v2`,
],
!process.env.CI && `gatsby-plugin-webpack-bundle-analyser-v2`,
].filter(Boolean),
}

/**
Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"description": "Gatsby MDX tester",
"version": "1.0.0",
"dependencies": {
"@mdx-js/mdx": "^1.6.6",
"@mdx-js/react": "^1.6.6",
"@mdx-js/react": "^2",
"cypress": "^7.2.0",
"fs-extra": "^8.1.0",
"gatsby": "^3.0.0",
"gatsby-plugin-mdx": "^2.0.0",
"gatsby-source-filesystem": "^3.0.0",
"gatsby": "^4.0.0",
"gatsby-plugin-mdx": "^3.0.0",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.27",
"gatsby-source-filesystem": "^4.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"theme-ui": "^0.3.1"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,19 @@ MDX seeks to make writing with Markdown and JSX simpler while being more express
- [Gatsby remark plugins](#gatsby-remark-plugins)
- [Remark plugins](#remark-plugins)
- [Rehype plugins](#rehype-plugins)
- [Media types](#media-types)
- [Explanation](#explanation)
- [shouldBlockNodeFromTransformation](#shouldblocknodefromtransformation)
- [Components](#components)
- [MDXProvider](#mdxprovider)
- [Related](#related)
- [MDXRenderer](#mdxrenderer)
- [Troubleshooting](#troubleshooting)
- [Excerpts for non-latin languages](#excerpts-for-non-latin-languages)
- [License](#license)

## Installation

Install:

```shell
npm install gatsby-plugin-mdx @mdx-js/mdx@v1 @mdx-js/react@v1
npm install gatsby-plugin-mdx @mdx-js/react
```

## Usage
Expand Down Expand Up @@ -113,16 +111,13 @@ module.exports = {
any other Gatsby plugin. You can define MDX extensions, layouts, global
scope, and more.

| Key | Default | Description |
| ------------------------------------------------------------------------- | -------------------------------------- | --------------------------------------------------------------------- |
| [`extensions`](#extensions) | `[".mdx"]` | Configure the file extensions that gatsby-plugin-mdx will process |
| [`defaultLayouts`](#default-layouts) | `{}` | Set the layout components for MDX source types |
| [`gatsbyRemarkPlugins`](#gatsby-remark-plugins) | `[]` | Use Gatsby-specific remark plugins |
| [`remarkPlugins`](#remark-plugins) | `[]` | Specify remark plugins |
| [`rehypePlugins`](#rehype-plugins) | `[]` | Specify rehype plugins |
| [`mediaTypes`](#media-types) | `["text/markdown", "text/x-markdown"]` | Determine which media types are processed by MDX |
| [`shouldBlockNodeFromTransformation`](#shouldblocknodefromtransformation) | `(node) => false` | Disable MDX transformation for nodes where this function returns true |
| [`commonmark`](#commonmark) | `false` | Use CommonMark |
| Key | Default | Description |
| ----------------------------------------------- | ---------- | ----------------------------------------------------------------- |
| [`extensions`](#extensions) | `[".mdx"]` | Configure the file extensions that gatsby-plugin-mdx will process |
| [`defaultLayouts`](#default-layouts) | `{}` | Set the layout components for MDX source types |
| [`gatsbyRemarkPlugins`](#gatsby-remark-plugins) | `[]` | Use Gatsby-specific remark plugins |
| [`remarkPlugins`](#remark-plugins) | `[]` | Specify remark plugins |
| [`rehypePlugins`](#rehype-plugins) | `[]` | Specify rehype plugins |

#### Extensions

Expand Down Expand Up @@ -411,61 +406,6 @@ module.exports = {
}
```

#### Media types

Deciding what content gets processed by `gatsby-plugin-mdx`. This is an
advanced option that is useful for dealing with specialized generated
content. It is not intended to be configured for most users.

```js
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
mediaTypes: [`text/markdown`, `text/x-markdown`],
},
},
],
}
```

##### Explanation

Gatsby includes the media-type of the content on any given node. For
`file` nodes, we choose whether to process the content with MDX or not
by the file extension. For remote content or generated content, we
choose which nodes to process by looking at the media type.

#### shouldBlockNodeFromTransformation

Given a function `(node) => Boolean` allows you to decide for each node if it should be transformed or not.

```js
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
shouldBlockNodeFromTransformation(node) {
return (
[`NPMPackage`, `NPMPackageReadme`].includes(node.internal.type) ||
(node.internal.type === `File` &&
path.parse(node.dir).dir.endsWith(`packages`))
)
},
},
},
],
}
```

#### CommonMark

MDX will be parsed using CommonMark.

### Components

MDX and `gatsby-plugin-mdx` use components for different things like rendering
Expand Down Expand Up @@ -541,41 +481,7 @@ You can also expose any custom component to every mdx file using

##### Related

- [MDX components](https://mdxjs.com/getting-started/#mdxprovider)

#### MDXRenderer

`MDXRenderer` is a React component that takes _compiled_ MDX content and
renders it. You will need to use this if your MDX content is coming
from a GraphQL page query or `StaticQuery`.

`MDXRenderer` takes any prop and passes it on to your MDX content,
just like a normal React component.

```jsx
<MDXRenderer title="My Stuff!">{mdx.body}</MDXRenderer>
```

Using a page query:

```jsx
import { MDXRenderer } from "gatsby-plugin-mdx"

export default class MyPageLayout {
render() {
return <MDXRenderer>{this.props.data.mdx.body}</MDXRenderer>
}
}

export const pageQuery = graphql`
query MDXQuery($id: String!) {
mdx(id: { eq: $id }) {
id
body
}
}
`
```
- [React context for MDX](https://mdxjs.com/packages/react/#use)

## Troubleshooting

Expand Down
13 changes: 9 additions & 4 deletions packages/gatsby-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@
"dependencies": {
"@mdx-js/loader": "^2.1.1",
"@mdx-js/mdx": "^2.1.1",
"change-case": "^4.1.2",
"fs-extra": "^10.1.0",
"gray-matter": "^4.0.3",
"mdast-util-from-markdown": "^1.2.0",
"mdast-util-mdxjs-esm": "^1.2.0",
"mdast-util-mdx": "^2.0.0",
"mdast-util-to-markdown": "^1.3.0",
"micromark-extension-mdxjs-esm": "^1.0.3"
"micromark-extension-mdxjs": "^1.0.0"
},
"devDependencies": {
"babel-preset-gatsby-package": "2.15.0-next.0",
"typescript": "^4.6.4"
},
"peerDependencies": {
"@mdx-js/mdx": "^2.0.0",
"@mdx-js/react": "^2.0.0",
"gatsby": "^4.0.0-next",
"gatsby-source-filesystem": "^4.0.0-next",
"loader-utils": "^3.2.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0"
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
"webpack": "^5.72.1"
}
}
Loading

0 comments on commit e0b26c8

Please sign in to comment.