-
Notifications
You must be signed in to change notification settings - Fork 7
/
theme.config.jsx
197 lines (177 loc) · 5.13 KB
/
theme.config.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import DocSearch from '@/components/DocSearch'
import Logo from '@/components/Logo'
import Link from 'next/link'
import { useRouter } from 'next/router'
import pkg from './package.json'
export default {
logo: Logo,
project: {
link: 'https://github.com/dream-num/univer',
},
chat: {
link: 'https://discord.gg/XPGnMBmpd6',
},
i18n: [
{ locale: 'en-US', text: 'English' },
{ locale: 'zh-CN', text: '简体中文' },
],
docsRepositoryBase: 'https://github.com/dream-num/univer.ai/tree/main',
head: null,
useNextSeoProps() {
return {
titleTemplate: '%s – Univer',
description: 'Univer is an open-source alternative to Google Sheets, Slides, and Docs',
openGraph: {
type: 'website',
locale: 'en_US',
url: 'https://univer.ai',
site_name: 'Univer',
images: [
{
url: 'https://univer.ai/images/og.png',
alt: 'Univer',
},
],
},
twitter: {
handle: '@univerhq',
site: '@univerhq',
cardType: 'summary_large_image',
},
}
},
search: {
component: () => (
<DocSearch />
),
},
banner: {
dismissible: true,
key: pkg.version,
text: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter()
const message = {
'zh-CN': `🎉 v${pkg.version} 版本已发布。查看详情 →`,
'en-US': `🎉 v${pkg.version} is released. Read more →`,
}
return (
<a href={`https://github.com/dream-num/univer/releases/tag/v${pkg.version}`} target="_blank">
{message[locale]}
</a>
)
},
},
sidebar: {
defaultMenuCollapseLevel: 3,
toggleButton: true,
titleComponent({ title }) {
const apiTitles = [
'classes',
'type-aliases',
'interfaces',
'variables',
'functions',
'namespaces',
'enumerations',
]
if (apiTitles.includes(title)) {
const initial = title.charAt(0).toUpperCase()
return (
<span className="flex gap-2 items-center">
<span className="font-semibold border-2 border-stone-700 rounded-md size-6 flex items-center justify-center">
{initial}
</span>
<span>
{initial}
{title.slice(1)}
</span>
</span>
)
}
else if (title.startsWith('@univerjs')) {
return <span className="font-semibold">{title}</span>
}
else {
return title
}
},
},
toc: {
title: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter()
const message = {
'zh-CN': '目录',
'en-US': 'Contents',
}
return message[locale]
},
backToTop: true,
},
feedback: {
content: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter()
const message = {
'zh-CN': '文档有问题?给我们反馈 ↗',
'en-US': 'Found a mistake in the docs? Let us know ↗',
}
return message[locale]
},
},
editLink: {
component: ({ className, filePath }) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { locale } = useRouter()
const message = {
'zh-CN': '在 GitHub 上编辑此页 ↗',
'en-US': 'Edit this page on GitHub ↗',
}
const uri = filePath.replace('src/pages', '')
const generalDocs = [
'/guides/sheet/introduction',
'/guides/doc/introduction',
'/guides/slide/introduction',
'/guides/sheet/getting-started/univer-plugins',
'/guides/doc/getting-started/univer-plugins',
'/guides/slide/getting-started/univer-plugins',
'/guides/sheet/advanced',
'/guides/doc/advanced',
'/guides/slide/advanced',
'/guides/sheet/architecture',
'/guides/doc/architecture',
'/guides/slide/architecture',
'/guides/sheet/getting-started/facade',
'/guides/doc/facade/facade',
'/guides/slide/facade/facade',
'/guides/sheet/features/facade',
'/guides/doc/features/facade',
'/guides/slide/features/facade',
'/guides/sheet/server',
'/guides/doc/server',
'/guides/slide/server',
'/guides/sheet/tutorials/find-the-command-id',
'/guides/doc/tutorials/find-the-command-id',
'/guides/slide/tutorials/find-the-command-id',
'/guides/sheet/contributing',
'/guides/doc/contributing',
'/guides/slide/contributing',
]
const isGeneralDoc = generalDocs.some(doc => uri.startsWith(doc))
const href = `https://github.com/dream-num/univer.ai/tree/main/src/docs${isGeneralDoc ? uri.replace(/(sheet|doc|slide)/, 'general') : uri}`
return (
<Link className={className} href={href} target="_blank" rel="noopener noreferrer">
{message[locale]}
</Link>
)
},
},
footer: {
text: (
<span>
Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.
</span>
),
},
}