From 86b4309f12aaaf8b1a0a18a485fe1db2e915cf4a Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 6 Aug 2019 14:01:27 +0200 Subject: [PATCH] portal: make portal compatible with new gatsby-plugin-mdx --- packages/dnb-design-system-portal/gatsby-config.js | 4 ++-- .../dnb-design-system-portal/src/templates/mdx.js | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/dnb-design-system-portal/gatsby-config.js b/packages/dnb-design-system-portal/gatsby-config.js index b8abf4695ad..9bafc4fdb45 100644 --- a/packages/dnb-design-system-portal/gatsby-config.js +++ b/packages/dnb-design-system-portal/gatsby-config.js @@ -38,7 +38,7 @@ module.exports = { { resolve: 'gatsby-plugin-page-creator', options: { - ignore: ['**/*.md', '**/Examples.js'], + ignore: ['**/*.md', '**/Examples.js', '**/*_not_in_use*'], path: `${__dirname}/src/docs`, // for .js files name: 'docs' } @@ -51,7 +51,7 @@ module.exports = { } }, { - resolve: 'gatsby-mdx', + resolve: 'gatsby-plugin-mdx', options: { extensions: ['.md'], // More info of using plugins: https://github.com/mdx-js/mdx/blob/d4154b8c4a546d0b675826826f85014cc04098c2/docs/plugins.md diff --git a/packages/dnb-design-system-portal/src/templates/mdx.js b/packages/dnb-design-system-portal/src/templates/mdx.js index 41ad40e5a81..2169555789c 100644 --- a/packages/dnb-design-system-portal/src/templates/mdx.js +++ b/packages/dnb-design-system-portal/src/templates/mdx.js @@ -7,7 +7,7 @@ import PropTypes from 'prop-types' import Head from 'react-helmet' import { MDXProvider } from '@mdx-js/react' -import MDXRenderer from 'gatsby-mdx/mdx-renderer' +import { MDXRenderer } from 'gatsby-plugin-mdx' import { graphql, withPrefix } from 'gatsby' import Layout from '../shared/parts/Layout' @@ -19,7 +19,7 @@ export default class MdxTemplate extends PureComponent { location, data: { mdx: { - code: { body }, + body, frontmatter: { title, description, fullscreen } }, site: { @@ -49,15 +49,13 @@ MdxTemplate.propTypes = { location: PropTypes.object.isRequired, data: PropTypes.shape({ mdx: PropTypes.shape({ - code: PropTypes.shape({ - body: PropTypes.string.isRequired - }).isRequired + body: PropTypes.string.isRequired }).isRequired }).isRequired } export const pageQuery = graphql` - query($id: String!) { + query MDXQuery($id: String!) { site { siteMetadata { description @@ -69,9 +67,7 @@ export const pageQuery = graphql` description fullscreen } - code { - body - } + body } } `