From 0fac8ef0ab913fb8a93fd715a638cdb24e1174f5 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 5 May 2023 17:07:47 +1200 Subject: [PATCH] ENH Make 5 the default version --- README.md | 1 + gatsby-node.js | 6 +++++- netlify.toml | 18 ++++++++++++------ src/pages/index.tsx | 2 +- src/utils/nodes.ts | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 31f767c..de5eeb5 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ For **new stable releases**, you will need to do the following - Remove the major from the `PRE_RELEASE` array in the `getVersionMessage` function in `src/utils/nodes.ts` - Update the `getDefaultVersion` function's return value to the new stable major in `src/utils/nodes.ts` - Update redirects in `netlify.toml` +- Update `index.tsx` to navigate to the new stable major When a **major goes EOL**, add the major to the `EOL` array in the `getVersionMessage` function in `src/utils/nodes.ts` diff --git a/gatsby-node.js b/gatsby-node.js index f4fcda9..cfdb889 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -144,11 +144,15 @@ exports.createPages = async ({ actions, graphql, getNodesByType }) => { console.log(`Creating legacy redirects...`); const redirects = new Map(); + const v5docs = getNodesByType('SilverstripeDocument').filter(n => n.slug.match(/^\/en\/5\//)); const v4docs = getNodesByType('SilverstripeDocument').filter(n => n.slug.match(/^\/en\/4\//)); const v3docs = getNodesByType('SilverstripeDocument').filter(n => n.slug.match(/^\/en\/3\//)); - [...v4docs, ...v3docs].forEach(n => { + [...v5docs, ...v4docs, ...v3docs].forEach(n => { const legacy = n.slug.replace(/^\/en\/[0-9]\//, '/en/'); + if (legacy === '/en/') { + return; + } if (!redirects.has(legacy)) { redirects.set(legacy, n.slug); } diff --git a/netlify.toml b/netlify.toml index 98c597c..58e48c6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,20 +2,26 @@ from = "https://doc.silverstripe.org/*" to = "https://docs.silverstripe.org/:splat" force = true - status = 301 + status = 302 [[redirects]] from = "/" - to = "/en/4/" + to = "/en/5/" + status = 302 + +[[redirects]] + from = "/en" + to = "/en/5/" + status = 302 [[redirects]] from = "/framework/en/*" - to = "/en/4/:splat" - status = 301 - + to = "/en/5/:splat" + status = 302 + [[redirects]] from = "/contributing" - to = "/en/4/contributing/" + to = "/en/5/contributing/" [[redirects]] from = "/en/4/getting_started/installation/common_problems" diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 23baedc..8c39d66 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -3,7 +3,7 @@ import { navigate } from '@reach/router' const IndexPage = () => { useEffect(() => { - navigate('/en/4/'); + navigate('/en/5/'); }, []); return
; diff --git a/src/utils/nodes.ts b/src/utils/nodes.ts index 76b0ded..33ffc05 100644 --- a/src/utils/nodes.ts +++ b/src/utils/nodes.ts @@ -143,7 +143,7 @@ const getHomePage = (): SilverstripeDocument | null => { /** * Get the default version */ -const getDefaultVersion = (): string => '4'; +const getDefaultVersion = (): string => '5'; /** * Get the selected version @@ -158,7 +158,7 @@ const getVersionMessage = (): ReactElement | ReactElement[] | string | null => { '3', ]; const PRE_RELEASE = [ - '5', + '6', ]; const version = getCurrentVersion(); const stablePath = getVersionPath(getCurrentNode(), getDefaultVersion());