diff --git a/nx-dev/nx-dev/next.config.js b/nx-dev/nx-dev/next.config.js index fe32522daedd2..2880cb7382d74 100644 --- a/nx-dev/nx-dev/next.config.js +++ b/nx-dev/nx-dev/next.config.js @@ -28,199 +28,17 @@ module.exports = withNx({ async redirects() { const rules = []; - // Tutorials - for (let s of Object.keys(redirectRules.tutorialRedirects)) { - rules.push({ - source: s, - destination: redirectRules.tutorialRedirects[s], - permanent: true, - }); + // Apply all the redirects from the redirect-rules.js file + for (const section of Object.keys(redirectRules)) { + for (const source of Object.keys(redirectRules[section])) { + rules.push({ + source: source, + destination: redirectRules[section][source], + permanent: true, + }); + } } - // Storybook - rules.push({ - source: '/(l|latest)/(r|react)/storybook/overview', - destination: '/storybook/overview-react', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(a|angular)/storybook/overview', - destination: '/storybook/overview-angular', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(a|angular|r|react)/storybook/executors', - destination: '/storybook/executors-storybook', - permanent: true, - }); - - // Nx Console - rules.push({ - source: '/nx-console', - destination: '/using-nx/console', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(a|angular)/storybook/overview', - destination: '/storybook/overview-angular', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(a|angular|r|react)/storybook/executors', - destination: '/storybook/executors-storybook', - permanent: true, - }); - - // Customs - for (let s of Object.keys(redirectRules.guideUrls)) { - rules.push({ - source: `/l/n${s}`, - destination: redirectRules.guideUrls[s], - permanent: true, - }); - - rules.push({ - source: `/l/r${s}`, - destination: redirectRules.guideUrls[s], - permanent: true, - }); - - rules.push({ - source: `/l/a${s}`, - destination: redirectRules.guideUrls[s], - permanent: true, - }); - - rules.push({ - source: s, - destination: redirectRules.guideUrls[s], - permanent: true, - }); - } - - // Generic, catch-all - rules.push({ - source: '/(l|latest|p|previous)/(a|angular|r|react|n|node)/:path*', - destination: '/:path*', - permanent: true, - }); - rules.push({ - source: '/(l|latest|p|previous)/:path*', - destination: '/:path*', - permanent: true, - }); - rules.push({ - source: '/(a|angular|r|react|n|node)/:path*', - destination: '/:path*', - permanent: true, - }); - - // Schemas (generators & executors) - for (let s of Object.keys(redirectRules.schemaUrls)) { - rules.push({ - source: s, - destination: redirectRules.schemaUrls[s], - permanent: true, - }); - } - - // Api overviews - for (let s of Object.keys(redirectRules.overviewUrls)) { - rules.push({ - source: s, - destination: redirectRules.overviewUrls[s], - permanent: true, - }); - } - // Api CLI redirection to Nx - for (let s of Object.keys(redirectRules.cliUrls)) { - rules.push({ - source: s, - destination: redirectRules.cliUrls[s], - permanent: true, - }); - } - - // Diataxis doc restructure - for (let s of Object.keys(redirectRules.diataxis)) { - rules.push({ - source: s, - destination: redirectRules.diataxis[s], - permanent: true, - }); - } - // Recipes doc restructure - for (let s of Object.keys(redirectRules.recipesUrls)) { - rules.push({ - source: s, - destination: redirectRules.recipesUrls[s], - permanent: true, - }); - } - // Nx Cloud restructure - for (let s of Object.keys(redirectRules.nxCloudUrls)) { - rules.push({ - source: s, - destination: redirectRules.nxCloudUrls[s], - permanent: true, - }); - } - // Tutorials / Getting started - for (let s of Object.keys(redirectRules.conceptUrls)) { - rules.push({ - source: s, - destination: redirectRules.conceptUrls[s], - permanent: true, - }); - } - - // Packages Indexes - for (let s of Object.keys(redirectRules.packagesIndexes)) { - rules.push({ - source: s, - destination: redirectRules.packagesIndexes[s], - permanent: true, - }); - } - // Packages Documents - for (let s of Object.keys(redirectRules.packagesDocuments)) { - rules.push({ - source: s, - destination: redirectRules.packagesDocuments[s], - permanent: true, - }); - } - // Plugins Documents - for (let s of Object.keys(redirectRules.pluginUrls)) { - rules.push({ - source: s, - destination: redirectRules.pluginUrls[s], - permanent: true, - }); - } - // References - for (let s of Object.keys(redirectRules.referenceUrls)) { - rules.push({ - source: s, - destination: redirectRules.referenceUrls[s], - permanent: true, - }); - } - // Nesting 5min tutorials in Getting Started - for (let s of Object.keys(redirectRules.nested5minuteTutorialUrls)) { - rules.push({ - source: s, - destination: redirectRules.nested5minuteTutorialUrls[s], - permanent: true, - }); - } - - // Docs - rules.push({ - source: '/docs', - destination: '/getting-started/intro', - permanent: true, - }); return rules; }, }); diff --git a/nx-dev/nx-dev/redirect-rules.js b/nx-dev/nx-dev/redirect-rules.js index d14d0c6783d44..a89a24a4a2e33 100644 --- a/nx-dev/nx-dev/redirect-rules.js +++ b/nx-dev/nx-dev/redirect-rules.js @@ -488,15 +488,15 @@ const standaloneTutorialRedirects = { '/getting-started/tutorials/react-standalone-tutorial', '/shared/react-standalone-tutorial/5-summary': '/getting-started/tutorials/react-standalone-tutorial', - 'shared/angular-standalone-tutorial/1-code-generation': + '/shared/angular-standalone-tutorial/1-code-generation': '/getting-started/tutorials/angular-standalone-tutorial', - 'shared/angular-standalone-tutorial/2-project-graph': + '/shared/angular-standalone-tutorial/2-project-graph': '/getting-started/tutorials/angular-standalone-tutorial', - 'shared/angular-standalone-tutorial/3-task-running': + '/shared/angular-standalone-tutorial/3-task-running': '/getting-started/tutorials/angular-standalone-tutorial', - 'shared/angular-standalone-tutorial/4-task-pipelines': + '/shared/angular-standalone-tutorial/4-task-pipelines': '/getting-started/tutorials/angular-standalone-tutorial', - 'shared/angular-standalone-tutorial/5-summary': + '/shared/angular-standalone-tutorial/5-summary': '/getting-started/tutorials/angular-standalone-tutorial', }; @@ -677,6 +677,22 @@ const referenceUrls = { '/changelog': '/reference/changelog', }; +const missingAndCatchAllRedirects = { + // missing + '/docs': '/getting-started/intro', + // catch all + '/(l|latest|p|previous)/(a|angular|r|react|n|node)/:path*': '/:path*', + '/(l|latest|p|previous)/:path*': '/:path*', + '/(a|angular|r|react|n|node)/:path*': '/:path*', + // Storybook + '/(l|latest)/(r|react)/storybook/overview': '/storybook/overview-react', + '/(l|latest)/(a|angular)/storybook/overview': '/storybook/overview-angular', + '/(l|latest)/(a|angular|r|react)/storybook/executors': + '/storybook/executors-storybook', + // Nx Console + '/nx-console': '/using-nx/console', +}; + /** * Public export API */ @@ -696,4 +712,5 @@ module.exports = { nested5minuteTutorialUrls, pluginUrls, referenceUrls, + missingAndCatchAllRedirects, };