Merge pull request #264 from creative-commoners/pulls/master/five

ENH Make 5 the default version
This commit is contained in:
Maxime Rainville 2023-05-08 09:24:56 +12:00 committed by GitHub
commit f3d5c4781b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 10 deletions

View File

@ -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`

View File

@ -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);
}

View File

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

View File

@ -3,7 +3,7 @@ import { navigate } from '@reach/router'
const IndexPage = () => {
useEffect(() => {
navigate('/en/4/');
navigate('/en/5/');
}, []);
return <div />;

View File

@ -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());