Skip to content

Commit 8592751

Browse files
committed
fix
Signed-off-by: faweizhao26 <faweizhao26@gmail.com>
1 parent 3a4fb6a commit 8592751

3 files changed

Lines changed: 72 additions & 5 deletions

File tree

docusaurus.config.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
const lightCodeTheme = require('prism-react-renderer/themes/github');
22
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
3-
const currentLocale = process.env.DOCUSAURUS_CURRENT_LOCALE || 'en';
4-
const docsLocaleSegment = currentLocale === 'zh-CN' ? 'cn' : 'en';
5-
const docsBaseUrl = `https://docs.ivorysql.org/${docsLocaleSegment}/ivorysql-doc/v5.1/v5.1`;
63

74
/** @type {import('@docusaurus/types').Config} */
85
const config = {
@@ -123,7 +120,7 @@ const config = {
123120
},
124121
{
125122
label: 'Installation',
126-
href: `${docsBaseUrl}/3.1#quick-installation`,
123+
to: '/docs-installation',
127124
},
128125
{
129126
label: 'Contribution Guidelines',
@@ -149,7 +146,7 @@ const config = {
149146
},
150147
{
151148
label: 'Ecological Cooperation',
152-
href: `${docsBaseUrl}/5.0`,
149+
to: '/docs-ecosystem',
153150
position: 'left'
154151
},
155152
{

src/pages/docs-ecosystem.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useEffect } from 'react';
2+
import Layout from '@theme/Layout';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4+
5+
const DOCS_BASE = 'https://docs.ivorysql.org';
6+
const DOCS_VERSION = 'v5.1/v5.1';
7+
8+
function buildTarget(locale) {
9+
const normalizedLocale = (locale || 'en').toLowerCase();
10+
const docsLocaleSegment = normalizedLocale.startsWith('zh') ? 'cn' : 'en';
11+
return `${DOCS_BASE}/${docsLocaleSegment}/ivorysql-doc/${DOCS_VERSION}/5.0`;
12+
}
13+
14+
export default function DocsEcosystemRedirect() {
15+
const { i18n } = useDocusaurusContext();
16+
const target = buildTarget(i18n.currentLocale);
17+
18+
useEffect(() => {
19+
if (typeof window === 'undefined') {
20+
return;
21+
}
22+
window.location.replace(target);
23+
}, [target]);
24+
25+
return (
26+
<Layout title="Redirecting...">
27+
<main style={{ padding: '2rem', textAlign: 'center' }}>
28+
<p>Redirecting to documentation...</p>
29+
<p>
30+
If you are not redirected, <a href={target}>click here</a>.
31+
</p>
32+
</main>
33+
</Layout>
34+
);
35+
}

src/pages/docs-installation.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useEffect } from 'react';
2+
import Layout from '@theme/Layout';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4+
5+
const DOCS_BASE = 'https://docs.ivorysql.org';
6+
const DOCS_VERSION = 'v5.1/v5.1';
7+
8+
function buildTarget(locale) {
9+
const normalizedLocale = (locale || 'en').toLowerCase();
10+
const docsLocaleSegment = normalizedLocale.startsWith('zh') ? 'cn' : 'en';
11+
return `${DOCS_BASE}/${docsLocaleSegment}/ivorysql-doc/${DOCS_VERSION}/3.1#quick-installation`;
12+
}
13+
14+
export default function DocsInstallationRedirect() {
15+
const { i18n } = useDocusaurusContext();
16+
const target = buildTarget(i18n.currentLocale);
17+
18+
useEffect(() => {
19+
if (typeof window === 'undefined') {
20+
return;
21+
}
22+
window.location.replace(target);
23+
}, [target]);
24+
25+
return (
26+
<Layout title="Redirecting...">
27+
<main style={{ padding: '2rem', textAlign: 'center' }}>
28+
<p>Redirecting to documentation...</p>
29+
<p>
30+
If you are not redirected, <a href={target}>click here</a>.
31+
</p>
32+
</main>
33+
</Layout>
34+
);
35+
}

0 commit comments

Comments
 (0)