Skip to content

Commit 46ca460

Browse files
committed
[optimize] i18n & a11y details of Wiki debugger
1 parent 49f6cbc commit 46ca460

5 files changed

Lines changed: 62 additions & 40 deletions

File tree

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Block, DocumentBlockModel, renderBlocks, WikiNode } from 'mobx-lark';
2+
import { observer } from 'mobx-react';
23
import { GetServerSideProps } from 'next';
3-
import { FC } from 'react';
4+
import { FC, useContext } from 'react';
45
import { Container } from 'react-bootstrap';
56

67
import { GitDiffView } from '../../../components/GitDiffView';
78
import { PageHead } from '../../../components/Layout/PageHead';
89
import documentStore from '../../../models/Document';
10+
import { I18nContext } from '../../../models/Translation';
911
import wikiStore from '../../../models/Wiki';
1012
import { lark } from '../../api/Lark/core';
1113

@@ -38,43 +40,43 @@ interface WikiDocumentDebuggerPageProps {
3840
renderableBlocks: Block<any, any, any>[];
3941
}
4042

41-
const WikiDocumentDebuggerPage: FC<WikiDocumentDebuggerPageProps> = ({
42-
node,
43-
rawBlocks,
44-
renderableBlocks,
45-
}) => {
46-
const title = `${node.title} - Debugger`;
47-
const rendered = renderBlocks(renderableBlocks);
48-
49-
return (
50-
<Container>
51-
<PageHead title={title} />
52-
<h1>{title}</h1>
53-
54-
<section>
55-
<h2>🔍Block diff</h2>
56-
57-
<GitDiffView
58-
oldFile={{
59-
fileName: 'raw-blocks.json',
60-
content: JSON.stringify(rawBlocks, null, 2),
61-
language: 'json',
62-
}}
63-
newFile={{
64-
fileName: 'renderable-blocks.json',
65-
content: JSON.stringify(renderableBlocks, null, 2),
66-
language: 'json',
67-
}}
68-
/>
69-
</section>
70-
71-
<section>
72-
<h2>📄Document</h2>
73-
74-
{rendered}
75-
</section>
76-
</Container>
77-
);
78-
};
43+
const WikiDocumentDebuggerPage: FC<WikiDocumentDebuggerPageProps> = observer(
44+
({ node, rawBlocks, renderableBlocks }) => {
45+
const { t } = useContext(I18nContext);
46+
47+
const title = `${node.title} - ${t('debugger')}`;
48+
const rendered = renderBlocks(renderableBlocks);
49+
50+
return (
51+
<Container>
52+
<PageHead title={title} />
53+
<h1>{title}</h1>
54+
55+
<section>
56+
<h2>🔍{t('block_diff')}</h2>
57+
58+
<GitDiffView
59+
oldFile={{
60+
fileName: 'raw-blocks.json',
61+
content: JSON.stringify(rawBlocks, null, 2),
62+
language: 'json',
63+
}}
64+
newFile={{
65+
fileName: 'renderable-blocks.json',
66+
content: JSON.stringify(renderableBlocks, null, 2),
67+
language: 'json',
68+
}}
69+
/>
70+
</section>
71+
72+
<section>
73+
<h2>📄{t('document')}</h2>
74+
75+
{rendered}
76+
</section>
77+
</Container>
78+
);
79+
},
80+
);
7981

8082
export default WikiDocumentDebuggerPage;

pages/wiki/[node_token]/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { Icon } from 'idea-react';
12
import { Block, renderBlocks, WikiNode } from 'mobx-lark';
23
import { GetStaticPaths, GetStaticProps } from 'next';
34
import { FC } from 'react';
4-
import { Container } from 'react-bootstrap';
5+
import { Button, Container } from 'react-bootstrap';
56
import { Minute, Second } from 'web-utility';
67

78
import { PageHead } from '../../../components/Layout/PageHead';
@@ -50,6 +51,16 @@ const WikiDocumentPage: FC<WikiDocumentPageProps> = ({ node, blocks }) => (
5051
<Container>
5152
<PageHead title={node.title} />
5253

54+
<aside className="text-end">
55+
<Button
56+
variant="outline-primary"
57+
size="sm"
58+
href={`/wiki/${node.node_token}/debugger`}
59+
>
60+
<Icon name="tools" />
61+
</Button>
62+
</aside>
63+
5364
{renderBlocks(blocks)}
5465
</Container>
5566
);

translation/en-US.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export default {
4545
// MDX Article
4646
article: 'Article',
4747
wiki: 'Wiki',
48+
debugger: 'Debugger',
49+
block_diff: 'Block Diff',
50+
document: 'Document',
4851

4952
// Search
5053
keywords: 'Keywords',

translation/zh-CN.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export default {
4343
// MDX Article
4444
article: '文章',
4545
wiki: '知识库',
46+
debugger: '调试器',
47+
block_diff: '区块差异',
48+
document: '文档',
4649

4750
// Search
4851
keywords: '关键词',

translation/zh-TW.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export default {
4343
// MDX Article
4444
article: '文章',
4545
wiki: '知識庫',
46+
debugger: '偵錯器',
47+
block_diff: '區塊差異',
48+
document: '文件',
4649

4750
// Search
4851
keywords: '關鍵詞',

0 commit comments

Comments
 (0)