From 75bdd027b98b8585dcd587eebbbebe611771651b Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 30 May 2020 17:08:59 +0200 Subject: [PATCH] nextjs does not support fallbacks for export because? --- .../{production-error/[code].js => production-error.js} | 4 ++-- docs/src/modules/components/AppFrame.js | 2 +- docs/src/modules/components/MarkdownDocs.js | 2 +- docs/src/pages.js | 5 ----- docs/src/pages/production-error/{[code].md => index.md} | 2 +- packages/material-ui-utils/src/formatMuiErrorMessage.js | 4 ++-- 6 files changed, 7 insertions(+), 12 deletions(-) rename docs/pages/{production-error/[code].js => production-error.js} (85%) rename docs/src/pages/production-error/{[code].md => index.md} (80%) diff --git a/docs/pages/production-error/[code].js b/docs/pages/production-error.js similarity index 85% rename from docs/pages/production-error/[code].js rename to docs/pages/production-error.js index 41af0bfeb96e51..d7fbd8912cca35 100644 --- a/docs/pages/production-error/[code].js +++ b/docs/pages/production-error.js @@ -2,10 +2,10 @@ import React from 'react'; import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; import { prepareMarkdown } from 'docs/src/modules/utils/parseMarkdown'; -const pageFilename = 'production-error/[code]'; +const pageFilename = 'production-error'; const requireDemo = require.context('docs/src/pages/production-error', false, /\.js$/); const requireRaw = require.context( - '!raw-loader!../../src/pages/production-error', + '!raw-loader!../src/pages/production-error', false, /\.(js|md)$/, ); diff --git a/docs/src/modules/components/AppFrame.js b/docs/src/modules/components/AppFrame.js index 39e0c8685a5901..1941475bb3b24a 100644 --- a/docs/src/modules/components/AppFrame.js +++ b/docs/src/modules/components/AppFrame.js @@ -188,7 +188,7 @@ function AppFrame(props) { let navIconClassName = ''; let appBarClassName = classes.appBar; - if (!activePage || activePage.disableDrawer === true) { + if (activePage?.disableDrawer === true) { disablePermanent = true; appBarClassName += ` ${classes.appBarHome}`; } else { diff --git a/docs/src/modules/components/MarkdownDocs.js b/docs/src/modules/components/MarkdownDocs.js index 8738232c6a91c4..4d0d00f2caf93d 100644 --- a/docs/src/modules/components/MarkdownDocs.js +++ b/docs/src/modules/components/MarkdownDocs.js @@ -100,7 +100,7 @@ function MarkdownDocs(props) { const { activePage, pages } = React.useContext(PageContext); const pageList = flattenPages(pages); - const currentPageNum = findIndex(pageList, (page) => page.pathname === activePage.pathname); + const currentPageNum = findIndex(pageList, (page) => page.pathname === activePage?.pathname); const currentPage = pageList[currentPageNum]; const prevPage = pageList[currentPageNum - 1]; const nextPage = pageList[currentPageNum + 1]; diff --git a/docs/src/pages.js b/docs/src/pages.js index 1b33705a77fd75..ae2778340a6276 100644 --- a/docs/src/pages.js +++ b/docs/src/pages.js @@ -129,11 +129,6 @@ const pages = [ ], }, { title: 'Component API', ...findPages[0] }, - { - title: 'Production Error', - pathname: '/production-error', - children: [{ pathname: '/production-error/[code]' }], - }, { pathname: '/styles', children: [ diff --git a/docs/src/pages/production-error/[code].md b/docs/src/pages/production-error/index.md similarity index 80% rename from docs/src/pages/production-error/[code].md rename to docs/src/pages/production-error/index.md index aa87aa59ae9391..09680d9c81e1ca 100644 --- a/docs/src/pages/production-error/[code].md +++ b/docs/src/pages/production-error/index.md @@ -6,4 +6,4 @@ We recommend using the development build when debugging this error. It will include additional warnings about potential problems. If you encounter an exception while using the production build, this page will reassemble the orrigianl text of the error. -{{"demo": "pages/production-error/[code]/ErrorDecoder.js", "hideToolbar": true, "bg": "inline"}} +{{"demo": "pages/production-error/ErrorDecoder.js", "hideToolbar": true, "bg": "inline"}} diff --git a/packages/material-ui-utils/src/formatMuiErrorMessage.js b/packages/material-ui-utils/src/formatMuiErrorMessage.js index 48025d866704f5..3d7b55219a199c 100644 --- a/packages/material-ui-utils/src/formatMuiErrorMessage.js +++ b/packages/material-ui-utils/src/formatMuiErrorMessage.js @@ -8,11 +8,11 @@ export default function formatMuiErrorMessage(code) { // loose mode is safe iff we're concatenating primitives // see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose /* eslint-disable prefer-template */ - let url = 'https://material-ui.com/production-error/' + code + '/?'; + let url = 'https://material-ui.com/production-error/?code=' + code; for (let i = 1; i < arguments.length; i += 1) { // rest params over-transpile for this case // eslint-disable-next-line prefer-rest-params - url += 'args[]=' + encodeURIComponent(arguments[i]) + '&'; + url += '&args[]=' + encodeURIComponent(arguments[i]); } return 'Minified Material-UI error #' + code + '; visit ' + url + ' for the full message.'; /* eslint-enable prefer-template */