Skip to content

Commit b22f460

Browse files
committed
fix(site): split class/function tutorial links by section and locale
1 parent 3d82c66 commit b22f460

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

site/src/components/Preview.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { styled } from '../styled';
33
import { keyframes } from '@stitches/react';
44
import Translate from '@docusaurus/Translate';
5+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
56

67
const fadeInUp = keyframes({
78
'0%': { opacity: 0, transform: 'translateY(30px)' },
@@ -217,6 +218,9 @@ const codeFunction = `
217218
}`
218219

219220
export function PreviewClassSyntax() {
221+
const { i18n } = useDocusaurusContext();
222+
const locale = i18n.currentLocale === 'en' ? 'en' : 'zh-cn';
223+
220224
return (
221225
<Container>
222226
<div>
@@ -234,6 +238,13 @@ export function PreviewClassSyntax() {
234238
<EcoTag>IoC Container</EcoTag>
235239
<EcoTag>TypeORM</EcoTag>
236240
</EcoStrip>
241+
242+
<StartButtonGroup>
243+
<StartButton href={`/tutorial/class/${locale}/`}>
244+
<Translate id="homepage.preview.startClass">Start Class Tutorial</Translate>
245+
<i className="iconfont icon-arrow-right" />
246+
</StartButton>
247+
</StartButtonGroup>
237248
</div>
238249

239250
<CodeWindow>
@@ -257,6 +268,9 @@ export function PreviewClassSyntax() {
257268
}
258269

259270
export function PreviewFunctionSyntax() {
271+
const { i18n } = useDocusaurusContext();
272+
const locale = i18n.currentLocale === 'en' ? 'en' : 'zh-cn';
273+
260274
return (
261275
<Container>
262276
<CodeWindow css={{ '@mobile': { order: 2 } }}>
@@ -292,12 +306,7 @@ export function PreviewFunctionSyntax() {
292306
<EcoTag>Lightweight</EcoTag>
293307
</EcoStrip>
294308
<StartButtonGroup>
295-
<StartButton href="/tutorial/class/zh-cn/">
296-
<Translate id="homepage.preview.startClass">Start Class Tutorial</Translate>
297-
<i className="iconfont icon-arrow-right" />
298-
</StartButton>
299-
300-
<StartButton href="/tutorial/function/zh-cn/">
309+
<StartButton href={`/tutorial/function/${locale}/`}>
301310
<Translate id="homepage.preview.startFunction">Start Functional Tutorial</Translate>
302311
<i className="iconfont icon-arrow-right" />
303312
</StartButton>

0 commit comments

Comments
 (0)