Skip to content

Commit 3ca65b5

Browse files
committed
fix: 修复构建错误和链接路径问题
1. 修复了中文侧边栏文件开头的空行问题 2. 修复了 index.md 文件中的导入路径问题(移除 .ts 扩展名) 3. 修复了英文侧边栏中的链接路径问题(添加 /en 前缀) 4. 安装了 markdown-it-mathjax3 依赖以支持数学公式
1 parent d831f0b commit 3ca65b5

File tree

10 files changed

+2422
-616
lines changed

10 files changed

+2422
-616
lines changed

.vitepress/config.mts

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
import { defineConfig } from 'vitepress';
1+
import { defineConfig, HeadConfig, resolveSiteDataByRoute } from 'vitepress';
2+
import {
3+
groupIconMdPlugin
4+
} from 'vitepress-plugin-group-icons';
5+
6+
const prod = !!process.env.VITEPRESS_PROD
27

38
// https://vitepress.dev/reference/site-config
49
export default defineConfig({
510
title: 'RustFS',
611
description: 'RustFS is a high-performance distributed object storage software built using Rust',
12+
rewrites: {
13+
'en/:rest*': ':rest*'
14+
},
15+
lastUpdated: true,
16+
cleanUrls: true,
17+
metaChunk: true,
718
themeConfig: {
819
siteTitle: false,
920
logo: { src: '/images/logo.svg', height: 24 },
1021
logoLink: { link: 'https://rustfs.com', target: '_blank' },
11-
editLink: { pattern: 'https://github.com/rustfs/docs.rustfs.com/edit/main/docs/:path'},
22+
editLink: { pattern: 'https://github.com/rustfs/docs.rustfs.com/edit/main/docs/:path' },
1223
socialLinks: [
1324
{ icon: 'github', link: 'https://github.com/rustfs/rustfs' },
1425
{ icon: 'twitter', link: 'https://twitter.com/rustfsofficial' },
@@ -66,10 +77,64 @@ export default defineConfig({
6677
],
6778
srcDir: 'docs',
6879
locales: {
69-
root: { label: 'English', link: '/en/', lang: 'en', dir: 'en' },
70-
zh: { label: '简体中文', link: '/zh/', lang: 'zh', dir: 'zh' },
80+
root: { label: 'English' },
81+
zh: { label: '简体中文' },
7182
},
7283
sitemap: {
7384
hostname: 'https://docs.rustfs.com',
7485
},
86+
markdown: {
87+
math: true,
88+
codeTransformers: [
89+
// We use `[!!code` in demo to prevent transformation, here we revert it back.
90+
{
91+
postprocess(code) {
92+
return code.replace(/\[\!\!code/g, '[!code')
93+
}
94+
}
95+
],
96+
config(md) {
97+
// TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
98+
const fence = md.renderer.rules.fence!
99+
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
100+
const { localeIndex = 'root' } = env
101+
const codeCopyButtonTitle = (() => {
102+
switch (localeIndex) {
103+
case 'es':
104+
return 'Copiar código'
105+
case 'fa':
106+
return 'کپی کد'
107+
case 'ko':
108+
return '코드 복사'
109+
case 'pt':
110+
return 'Copiar código'
111+
case 'ru':
112+
return 'Скопировать код'
113+
case 'zh':
114+
return '复制代码'
115+
default:
116+
return 'Copy code'
117+
}
118+
})()
119+
return fence(tokens, idx, options, env, self).replace(
120+
'<button title="Copy Code" class="copy"></button>',
121+
`<button title="${codeCopyButtonTitle}" class="copy"></button>`
122+
)
123+
}
124+
md.use(groupIconMdPlugin)
125+
}
126+
},
127+
transformPageData: prod
128+
? (pageData, ctx) => {
129+
const site = resolveSiteDataByRoute(
130+
ctx.siteConfig.site,
131+
pageData.relativePath
132+
)
133+
const title = `${pageData.title || site.title} | ${pageData.description || site.description}`
134+
; ((pageData.frontmatter.head ??= []) as HeadConfig[]).push(
135+
['meta', { property: 'og:locale', content: site.lang }],
136+
['meta', { property: 'og:title', content: title }]
137+
)
138+
}
139+
: undefined
75140
});

docs/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { enSidebar } from './en/sidebar';
33

44
export default defineAdditionalConfig({
55
lang: 'en-US',
6-
description: 'Vite & Vue powered static site generator.',
6+
description: 'RustFS - MinIO alternative, high-performance distributed storage',
77

88
themeConfig: {
99
nav: [
@@ -16,7 +16,7 @@ export default defineAdditionalConfig({
1616
],
1717

1818
sidebar: {
19-
'/en/': enSidebar,
19+
'/': enSidebar,
2020
},
2121

2222
editLink: {

docs/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar: false
44
---
55

66
<script setup>
7-
import { enSidebar } from './sidebar.ts'
7+
import { enSidebar } from './sidebar';
88
</script>
99

1010
<Home :sidebar="enSidebar" title="RustFS Documentation" />

docs/en/sidebar.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ export const enSidebar = [
44
collapsed: true,
55
home: true,
66
items: [
7-
{ text: 'What is RustFS', link: '/en/introduction' },
8-
{ text: 'Architecture', link: '/en/architecture' },
9-
{ text: 'Comparison with Other Storage', link: '/en/comparison' },
10-
{ text: 'Open Source License', link: '/en/license' },
7+
{ text: 'What is RustFS', link: '/introduction' },
8+
{ text: 'Architecture', link: '/architecture' },
9+
{ text: 'Comparison with Other Storage', link: '/comparison' },
10+
{ text: 'Open Source License', link: '/license' },
1111
{
12-
text: 'Core Concepts', link: '/en/concepts/glossary',
12+
text: 'Core Concepts', link: '/concepts/glossary',
1313
items: [
14-
{ text: 'Glossary', link: '/en/concepts/glossary' },
15-
{ text: 'Erasure Coding', link: '/en/concepts/erasure-coding' },
16-
{ text: 'Availability and Resiliency', link: '/en/concepts/availability-and-resiliency' },
17-
{ text: 'Object Healing and Auto Recovery', link: '/en/concepts/object-healing' },
18-
{ text: 'Object Scanner', link: '/en/concepts/object-scanner' },
19-
{ text: 'Usage Limits', link: '/en/concepts/limit' },
14+
{ text: 'Glossary', link: '/concepts/glossary' },
15+
{ text: 'Erasure Coding', link: '/concepts/erasure-coding' },
16+
{ text: 'Availability and Resiliency', link: '/concepts/availability-and-resiliency' },
17+
{ text: 'Object Healing and Auto Recovery', link: '/concepts/object-healing' },
18+
{ text: 'Object Scanner', link: '/concepts/object-scanner' },
19+
{ text: 'Usage Limits', link: '/concepts/limit' },
2020
],
2121
},
2222
],
@@ -71,27 +71,27 @@ export const enSidebar = [
7171
collapsed: true,
7272
home: true,
7373
items: [
74-
{ text: 'Startup Modes', link: '/en/installation/mode/' },
75-
{ text: 'Hardware Selection', link: '/en/installation/hardware-selection' },
74+
{ text: 'Startup Modes', link: '/installation/mode/' },
75+
{ text: 'Hardware Selection', link: '/installation/hardware-selection' },
7676
{
7777
text: 'Pre-installation Checks',
78-
link: '/en/installation/checklists',
78+
link: '/installation/checklists',
7979
items: [
80-
{ text: 'Checklists', link: '/en/installation/checklists' },
81-
{ text: 'Hardware Checklists', link: '/en/installation/hard-checklists' },
82-
{ text: 'Software Checklists', link: '/en/installation/software-checklists' },
83-
{ text: 'Network Checklists', link: '/en/installation/network-checklists' },
84-
{ text: 'Security Checklists', link: '/en/installation/security-checklists' },
80+
{ text: 'Checklists', link: '/installation/checklists' },
81+
{ text: 'Hardware Checklists', link: '/installation/hard-checklists' },
82+
{ text: 'Software Checklists', link: '/installation/software-checklists' },
83+
{ text: 'Network Checklists', link: '/installation/network-checklists' },
84+
{ text: 'Security Checklists', link: '/installation/security-checklists' },
8585
]
8686
},
8787
{
8888
text: 'Installation Guides',
89-
link: '/en/installation/linux',
89+
link: '/installation/linux',
9090
items: [
91-
{ text: 'Linux Installation', link: '/en/installation/linux' },
92-
{ text: 'macOS Installation', link: '/en/installation/macos/' },
93-
{ text: 'Windows Installation', link: '/en/installation/windows/' },
94-
{ text: 'Docker Installation', link: '/en/installation/docker' },
91+
{ text: 'Linux Installation', link: '/installation/linux' },
92+
{ text: 'macOS Installation', link: '/installation/macos/' },
93+
{ text: 'Windows Installation', link: '/installation/windows/' },
94+
{ text: 'Docker Installation', link: '/installation/docker' },
9595
]
9696
},
9797
]
@@ -101,11 +101,11 @@ export const enSidebar = [
101101
collapsed: true,
102102
home: true,
103103
items: [
104-
{ text: 'SDK Overview', link: '/en/sdk/' },
105-
{ text: 'Java SDK', link: '/en/sdk/java' },
106-
{ text: 'Python SDK', link: '/en/sdk/python' },
107-
{ text: 'JavaScript SDK', link: '/en/sdk/js' },
108-
{ text: 'Other SDKs', link: '/en/sdk/other' },
104+
{ text: 'SDK Overview', link: '/sdk/' },
105+
{ text: 'Java SDK', link: '/sdk/java' },
106+
{ text: 'Python SDK', link: '/sdk/python' },
107+
{ text: 'JavaScript SDK', link: '/sdk/js' },
108+
{ text: 'Other SDKs', link: '/sdk/other' },
109109
]
110110
}
111111
]

docs/index.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/zh/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { defineAdditionalConfig } from 'vitepress'
22
import { zhSidebar } from './sidebar'
33

44
export default defineAdditionalConfig({
5-
lang: 'zh-CN',
6-
description: 'Vite & Vue powered static site generator.',
5+
lang: 'zh-Hans',
6+
description: 'RustFS - MinIO 国产化替代方案, 高性能分布式存储',
77

88
themeConfig: {
99
nav: [

docs/zh/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar: false
44
---
55

66
<script setup>
7-
import { zhSidebar } from './sidebar.ts'
7+
import { zhSidebar } from './sidebar';
88
</script>
99

1010
<Home :sidebar="zhSidebar" title="RustFS 文档中心" />

docs/zh/sidebar.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export const zhSidebar = [
32
{
43
text: '介绍',

0 commit comments

Comments
 (0)