Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Fix Next.js v13.5.1 <title> SEO regression #40302

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

@Janpot Janpot Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviertassinari Any idea what caused us to add this --threads=3? It doesn't seem to translate anywhere in the output: 'export' setup.

edit: got it, netlify resource issues it seems

edit 2: checked the next.js source code and it seems that option is now coming from experimental.cpus.

"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.

Loading