-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
208 lines (192 loc) · 4.36 KB
/
docusaurus.config.js
File metadata and controls
208 lines (192 loc) · 4.36 KB
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
198
199
200
201
202
203
204
205
206
207
208
// @ts-check
/* Environment variables */
const BRAND = process.env.BRAND ?? "tds";
const REGION = process.env.REGION ?? "cn";
const PREVIEW = process.env.PREVIEW ?? "false";
/* Configs for different versions */
const CONFIG_TDS_CN = {
root: {
title: "TapTap 开发者文档",
url: "https://developer.taptap.com",
baseUrl: PREVIEW === "true" ? "/" : "/docs/",
favicon: "/img/favicon.ico",
},
custom: {
searchUrl: "https://tds-doc-search-api.cn-e1.leanapp.cn/search",
mainDomainHost: "https://www.taptap.com",
dcDomainHost: "https://developer.taptap.com",
},
keywords: "taptap tds 开发者 文档",
i18n: { defaultLocale: "zh-Hans", locales: ["zh-Hans", "en"] },
};
const CONFIG_TDS_GLOBAL = {
root: {
title: "TapTap Developer Documentation",
url: "https://developer.taptap.io",
baseUrl: PREVIEW === "true" ? "/" : "/docs/",
favicon: "/img/favicon.ico",
},
custom: {
searchUrl: "https://tds-doc-search-api.avosapps.us/search",
mainDomainHost: "https://www.taptap.io",
dcDomainHost: "https://developer.taptap.io",
},
keywords: "taptap tds developer documentation",
i18n: { defaultLocale: "en", locales: ["en"] },
};
const CONFIG_LEANCLOUD_CN = {
root: {
title: "LeanCloud 开发者文档",
url: "https://docs.leancloud.cn",
baseUrl: "/",
favicon: "/img/lc-favicon.ico",
},
custom: {
searchUrl: "", // TODO
mainDomainHost: "https://www.leancloud.cn",
dcDomainHost: "https://www.leancloud.cn",
},
keywords: "leancloud 开发者 文档",
i18n: { defaultLocale: "zh-Hans", locales: ["zh-Hans"] },
};
const CONFIG =
BRAND === "tds"
? REGION === "cn"
? CONFIG_TDS_CN
: CONFIG_TDS_GLOBAL
: CONFIG_LEANCLOUD_CN;
/* Navbar items for different versions */
const NAVBAR_ITEMS_COMMON = [
{
label: "文档首页",
to: "/",
position: "right",
activeBaseRegex: "^" + CONFIG.root.baseUrl + "(?!.+)",
},
];
const NAVBAR_ITEMS_TDS = [
...NAVBAR_ITEMS_COMMON,
{
label: "游戏商店",
to: "store",
position: "right",
},
];
const NAVBAR_ITEMS_TDS_CN = [
...NAVBAR_ITEMS_TDS,
{
label: "游戏服务",
to: "sdk",
position: "right",
},
{
label: "API",
to: "/sdk-api",
position: "right",
},
{
label: "下载",
position: "right",
items: [
{
label: "设计资源",
to: "/design",
},
{
label: "SDK工具包",
to: "/tap-download",
},
{
label: "Demos",
to: "/demos",
},
],
},
{
type: "docsVersionDropdown",
position: "right",
},
{
type: "localeDropdown",
position: "right",
},
];
const NAVBAR_ITEMS =
BRAND === "tds"
? REGION === "cn"
? NAVBAR_ITEMS_TDS_CN
: NAVBAR_ITEMS_TDS
: NAVBAR_ITEMS_COMMON;
/** @type {import('@docusaurus/types').Config} */
const config = {
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
organizationName: "taptap",
projectName: "tds-docs",
trailingSlash: true,
...CONFIG.root,
customFields: {
brand: BRAND,
region: REGION,
...CONFIG.custom,
},
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve("./sidebars.js"),
routeBasePath: "/",
lastVersion: "current",
versions: {
current: {
label: "v3",
},
},
},
theme: {
customCss: require.resolve("./src/styles/index.scss"),
},
googleAnalytics: {
trackingID: "UA-73963350-1",
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
navbar: {
items: NAVBAR_ITEMS,
},
prism: {
theme: require("./src/theme/prism-taptap"),
additionalLanguages: ["csharp", "java", "php", "groovy"],
},
image: "/img/logo.svg",
metadata: [
{
name: "keywords",
content: CONFIG.keywords,
},
],
colorMode: {
defaultMode: "light",
disableSwitch: true,
},
}),
i18n: {
localeConfigs: {
en: {
label: "English",
},
"zh-Hans": {
label: "简体中文",
},
},
...CONFIG.i18n,
},
plugins: ["docusaurus-plugin-sass"],
};
module.exports = config;