Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
fix: Component in docs ignore error (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangkailang authored Aug 15, 2019
1 parent 0e153d0 commit 0890682
Show file tree
Hide file tree
Showing 5 changed files with 411 additions and 52 deletions.
7 changes: 6 additions & 1 deletion docs/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ module.exports = {
name: `content`,
},
},
`gatsby-mdx`,
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
},
},
`gatsby-plugin-typescript`,
`gatsby-plugin-react-helmet`,
`gatsby-transformer-react-docgen`,
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@types/react-dom": "^16.8.4",
"bootstrap-sass": "3.4.1",
"gatsby": "^2.8.2",
"gatsby-mdx": "^0.6.3",
"gatsby-plugin-manifest": "^2.1.1",
"gatsby-plugin-mdx": "^1.0.24",
"gatsby-plugin-offline": "^2.1.1",
"gatsby-plugin-react-helmet": "^3.0.12",
"gatsby-plugin-sass": "^2.0.11",
Expand Down
8 changes: 3 additions & 5 deletions docs/src/templates/components-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Playground from '../components/Playground';
import SideNav from '../components/SideNav';
import Header from '../components/Header';
import Toc from '../components/Toc';
import MDXRenderer from 'gatsby-mdx/mdx-renderer';
import { MDXRenderer } from 'gatsby-plugin-mdx';

const components = {
h2: props => <LinkedHeading h="3" {...props} />,
Expand Down Expand Up @@ -37,7 +37,7 @@ class BlogPostTemplate extends React.Component {
<div className="Main__Body">
<Header post={post} />
<MDXProvider components={components}>
<MDXRenderer>{post.code.body}</MDXRenderer>
<MDXRenderer>{post.body}</MDXRenderer>
</MDXProvider>
</div>
<div className="prev-next-nav">
Expand Down Expand Up @@ -73,9 +73,7 @@ export const pageQuery = graphql`
mdx(fields: { slug: { eq: $slug } }) {
id
excerpt(pruneLength: 160)
code {
body
}
body
fields {
slug
}
Expand Down
8 changes: 3 additions & 5 deletions docs/src/templates/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Playground from '../components/Playground';
import { MDXProvider } from '@mdx-js/react';
import { graphql } from 'gatsby';
import Header from '../components/Header';
import MDXRenderer from 'gatsby-mdx/mdx-renderer';
import { MDXRenderer } from 'gatsby-plugin-mdx';

const showComponents = {
code: props => <Playground {...props} isShow />,
Expand All @@ -17,7 +17,7 @@ export default props => {
<Layout>
<Header post={post} />
<MDXProvider components={showComponents}>
<MDXRenderer>{post.code.body}</MDXRenderer>
<MDXRenderer>{post.body}</MDXRenderer>
</MDXProvider>
</Layout>
);
Expand All @@ -28,9 +28,7 @@ export const pageQuery = graphql`
mdx(fields: { slug: { eq: $slug } }) {
id
excerpt(pruneLength: 160)
code {
body
}
body
fields {
slug
}
Expand Down
Loading

0 comments on commit 0890682

Please sign in to comment.