Skip to content

Commit

Permalink
[docs] Fix Next.js v13.5.1 <title> SEO regression (mui#40302)
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
  • Loading branch information
oliviertassinari and samuelsycamore authored Feb 9, 2024
1 parent f038c85 commit 5ae79e6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Clicking on **Details** will show you the differences.
#### deploy/netlify

This renders a preview of the docs with your changes if it succeeds.
Otherwise `pnpm docs:build` or `pnpm docs:export` usually fail locally as well.
Otherwise `pnpm docs:build` usually fails locally as well.

#### codecov/project

Expand Down
26 changes: 17 additions & 9 deletions docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export default withDocsInfra({
? `Basic ${Buffer.from(process.env.GITHUB_AUTH).toString('base64')}`
: '',
},
distDir: 'export',
// Next.js provides a `defaultPathMap` argument, we could simplify the logic.
// However, we don't in order to prevent any regression in the `findPages()` method.
// @ts-ignore
Expand Down Expand Up @@ -232,13 +233,20 @@ export default withDocsInfra({

return map;
},
// rewrites has no effect when run `next export` for production
rewrites: async () => {
return [
{ source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' },
// Make sure to include the trailing slash if `trailingSlash` option is set
{ source: '/api/:rest*/', destination: '/api-docs/:rest*/' },
{ source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' },
];
},
// Used to signal we run yarn build
...(process.env.NODE_ENV === 'production'
? {
output: 'export',
}
: {
// rewrites has no effect when run `next export` for production
rewrites: async () => {
return [
{ source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' },
// Make sure to include the trailing slash if `trailingSlash` option is set
{ source: '/api/:rest*/', destination: '/api-docs/:rest*/' },
{ source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' },
];
},
}),
});
5 changes: 2 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"author": "MUI Team",
"license": "MIT",
"scripts": {
"build": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile",
"build": "rimraf docs/export && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile && pnpm build-sw",
"build:clean": "rimraf .next && pnpm build",
"build-sw": "node ./scripts/buildServiceWorker.js",
"dev": "next dev",
"deploy": "git push -f material-ui-docs master:latest",
"export": "rimraf docs/export && next export --threads=3 -o export && pnpm build-sw",
"icons": "rimraf --glob public/static/icons/* && node ./scripts/buildIcons.js",
"start": "next start",
"create-playground": "cpy --cwd=scripts playground.template.tsx ../../pages/playground --rename=index.tsx",
Expand Down Expand Up @@ -84,7 +83,7 @@
"lz-string": "^1.5.0",
"markdown-to-jsx": "^7.4.1",
"material-ui-popup-state": "^5.0.10",
"next": "13.5.1",
"next": "^13.5.1",
"notistack": "3.0.1",
"nprogress": "^0.2.0",
"postcss": "^8.4.33",
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
publish = "docs/export/"

# Default build command.
command = "pnpm docs:build && pnpm docs:export"
command = "pnpm docs:build"

[build.environment]
NODE_VERSION = "18"
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"docs:build-color-preview": "babel-node scripts/buildColorTypes",
"docs:deploy": "pnpm --filter docs run deploy",
"docs:dev": "pnpm --filter docs dev",
"docs:export": "pnpm --filter docs export",
"docs:icons": "pnpm --filter docs icons",
"docs:size-why": "cross-env DOCS_STATS_ENABLED=true pnpm docs:build",
"docs:start": "pnpm --filter docs start",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ae79e6

Please sign in to comment.