From 0fe4f87072d94951b9cdf6a3dc5028ed22475575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Bl=C3=A4ttermann?= Date: Mon, 14 Nov 2022 00:34:44 +0100 Subject: [PATCH] Remove outdated MDX handling --- website/src/templates/index.js | 23 ++--------------------- website/src/templates/mdx-renderer.js | 21 --------------------- 2 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 website/src/templates/mdx-renderer.js diff --git a/website/src/templates/index.js b/website/src/templates/index.js index 0b48f6e93..1f0ccf1f5 100644 --- a/website/src/templates/index.js +++ b/website/src/templates/index.js @@ -1,12 +1,8 @@ import React from 'react' import PropTypes from 'prop-types' -import { MDXProvider } from '@mdx-js/tag' -import { withMDXScope } from 'gatsby-mdx/context' import useOnlineStatus from '@rehooks/online-status' import classNames from 'classnames' -import MDXRenderer from './mdx-renderer' - // Templates import Docs from './docs' import Universe from './universe' @@ -73,13 +69,6 @@ class Layout extends React.Component { } static propTypes = { - data: PropTypes.shape({ - mdx: PropTypes.shape({ - code: PropTypes.shape({ - body: PropTypes.string.isRequired, - }).isRequired, - }), - }).isRequired, scope: PropTypes.object.isRequired, pageContext: PropTypes.shape({ title: PropTypes.string, @@ -106,18 +95,11 @@ class Layout extends React.Component { } render() { - const { data, pageContext, location, children } = this.props - const { file, site = {} } = data || {} - const mdx = file ? file.childMdx : null + const { pageContext, location, children } = this.props const { title, section, sectionTitle, teaser, theme = 'blue', searchExclude } = pageContext const uiTheme = nightly ? 'nightly' : legacy ? 'legacy' : theme const bodyClass = classNames(`theme-${uiTheme}`, { 'search-exclude': !!searchExclude }) const isDocs = ['usage', 'models', 'api', 'styleguide'].includes(section) - const content = !mdx ? null : ( - - {mdx.code.body} - - ) return ( <> @@ -150,7 +132,6 @@ class Layout extends React.Component { ) : (
{children} - {content}
)} @@ -159,4 +140,4 @@ class Layout extends React.Component { } } -export default withMDXScope(Layout) +export default Layout diff --git a/website/src/templates/mdx-renderer.js b/website/src/templates/mdx-renderer.js deleted file mode 100644 index efdfc21d6..000000000 --- a/website/src/templates/mdx-renderer.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Temporary hack to prevent this issue: - * https://github.com/ChristopherBiscardi/gatsby-mdx/issues/244 - */ - -import React from 'react' -import { MDXTag } from '@mdx-js/tag' -import { withMDXComponents } from '@mdx-js/tag/dist/mdx-provider' -import { withMDXScope } from 'gatsby-mdx/context' - -const WrappedComponent = React.memo(({ scope = {}, components = {}, children, ...props }) => { - if (!children) return null - const fullScope = { React, MDXTag, ...scope } - const keys = Object.keys(fullScope) - const values = keys.map((key) => fullScope[key]) - const fn = new Function('_fn', ...keys, `${children}`) // eslint-disable-line no-new-func - const End = fn({}, ...values) - return React.createElement(End, { components, ...props }) -}) - -export default withMDXScope(withMDXComponents(WrappedComponent))