From 9e07cf41461712c34759879af8b14df351904afc Mon Sep 17 00:00:00 2001 From: Benjamin Cabanes <3447705+bcabanes@users.noreply.github.com> Date: Fri, 13 Jan 2023 10:37:58 -0500 Subject: [PATCH] docs(nxdev): add tutorial redirect rules (#14346) closes https://github.com/nrwl/nx/issues/14134 --- nx-dev/nx-dev/next.config.js | 25 ++++----------------- nx-dev/nx-dev/redirect-rules.config.js | 23 +++++++++++++++---- nx-dev/nx-dev/redirect-rules.config.spec.js | 6 ++--- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/nx-dev/nx-dev/next.config.js b/nx-dev/nx-dev/next.config.js index fba832bf9a8ae..37bf917f9bbc9 100644 --- a/nx-dev/nx-dev/next.config.js +++ b/nx-dev/nx-dev/next.config.js @@ -5,7 +5,7 @@ const path = require('path'); const redirectRules = require('./redirect-rules.config'); /** - * TODO@ben: Temporary solution before Nextjs' assets management tasks is up and running + * TODO@ben: Use watch method instead. */ copySync( path.resolve(__dirname + '/../../docs'), @@ -43,27 +43,10 @@ module.exports = withNx({ const rules = []; // Tutorials - rules.push({ - source: '/(l|latest)/(r|react)/tutorial/1-code-generation', - destination: '/react-tutorial/1-code-generation', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(a|angular)/tutorial/1-code-generation', - destination: '/angular-tutorial/1-code-generation', - permanent: true, - }); - rules.push({ - source: '/(l|latest)/(n|node)/tutorial/1-code-generation', - destination: '/node-tutorial/1-code-generation', - permanent: true, - }); - for (const [source, destination] of Object.entries( - redirectRules.tutorialRedirects - )) { + for (let s of Object.keys(redirectRules.tutorialRedirects)) { rules.push({ - source, - destination, + source: s, + destination: redirectRules.tutorialRedirects[s], permanent: true, }); } diff --git a/nx-dev/nx-dev/redirect-rules.config.js b/nx-dev/nx-dev/redirect-rules.config.js index 0ccc2025cab5f..90a95ddc1b170 100644 --- a/nx-dev/nx-dev/redirect-rules.config.js +++ b/nx-dev/nx-dev/redirect-rules.config.js @@ -333,8 +333,21 @@ const nxCloudUrls = { }; /** - * Tutorial Updates + * Tutorial Updates (updated 2023-01-13) */ +const tutorialBaseUrls = { + '/(l|latest)/(a|angular)/tutorial/1-code-generation': + '/getting-started/angular-standalone-tutorial', + '/(l|latest)/(a|node)/tutorial/1-code-generation': + '/getting-started/node-tutorial', + '/(l|latest)/(r|react)/tutorial/1-code-generation': + '/getting-started/react-standalone-tutorial', + '/angular-tutorial/1-code-generation': + '/getting-started/angular-standalone-tutorial', + '/node-tutorial/1-code-generation': '/getting-started/node-tutorial', + '/react-tutorial/1-code-generation': + '/getting-started/react-standalone-tutorial', +}; const oldReactTutorialPaths = [ '/react-tutorial/01-create-application', '/react-tutorial/02-add-e2e-test', @@ -349,7 +362,7 @@ const oldReactTutorialPaths = [ '/react-tutorial/11-test-affected-projects', '/react-tutorial/12-summary', ]; -const reactRedirectDestination = '/react-tutorial/1-code-generation'; +const reactRedirectDestination = '/getting-started/react-standalone-tutorial'; const reactTutorialRedirects = oldReactTutorialPaths.reduce((acc, path) => { acc[path] = reactRedirectDestination; return acc; @@ -364,12 +377,13 @@ const oldNodeTutorialPaths = [ '/node-tutorial/07-test-affected-projects', '/node-tutorial/08-summary', ]; -const nodeRedirectDestination = '/node-tutorial/1-code-generation'; +const nodeRedirectDestination = '/getting-started/node-tutorial'; const nodeTutorialRedirects = oldNodeTutorialPaths.reduce((acc, path) => { acc[path] = nodeRedirectDestination; return acc; }, {}); const tutorialRedirects = Object.assign( + tutorialBaseUrls, reactTutorialRedirects, nodeTutorialRedirects ); @@ -389,7 +403,8 @@ const oldAngularTutorialPaths = [ '/angular-tutorial/12-summary', ]; -const angularRedirectDestination = '/angular-tutorial/1-code-generation'; +const angularRedirectDestination = + '/getting-started/angular-standalone-tutorial'; for (const path of oldAngularTutorialPaths) { tutorialRedirects[path] = angularRedirectDestination; } diff --git a/nx-dev/nx-dev/redirect-rules.config.spec.js b/nx-dev/nx-dev/redirect-rules.config.spec.js index e5e35273269c0..c470caf8b56de 100644 --- a/nx-dev/nx-dev/redirect-rules.config.spec.js +++ b/nx-dev/nx-dev/redirect-rules.config.spec.js @@ -37,7 +37,7 @@ describe('Redirect rules configuration', () => { for (const url of oldReactUrls) { expect(redirectRules.tutorialRedirects[url]).toEqual( - '/react-tutorial/1-code-generation' + '/getting-started/react-standalone-tutorial' ); } }); @@ -60,7 +60,7 @@ describe('Redirect rules configuration', () => { for (const url of oldAngularUrls) { expect(redirectRules.tutorialRedirects[url]).toEqual( - '/angular-tutorial/1-code-generation' + '/getting-started/angular-standalone-tutorial' ); } }); @@ -79,7 +79,7 @@ describe('Redirect rules configuration', () => { for (const url of oldNodeTutorialPaths) { expect(redirectRules.tutorialRedirects[url]).toEqual( - '/node-tutorial/1-code-generation' + '/getting-started/node-tutorial' ); } });