forked from NervJS/taro-docs
-
Notifications
You must be signed in to change notification settings - Fork 6
/
docusaurus.config.js
356 lines (344 loc) · 9.39 KB
/
docusaurus.config.js
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// See https://docusaurus.io/docs/site-config.html for all the possible
// site configuration options.
const uniqueCommitId = require('unique-commit-id')
const versions = require('./versions.json')
const path = require('path')
const BASE_DOMAIN = process.env.BASE || 'taro'
const url = {
jd: 'https://taro-docs.jd.com',
taro: 'https://nervjs.github.io',
zone: 'https://docs.taro.zone',
}
const baseUrl = {
jd: '/',
taro: '/taro-docs/',
zone: '/',
}
const imgBaseUrl = {
jd: `//storage.360buyimg.com/pubfree-bucket/taro-docs/${uniqueCommitId.latest()}/img`,
taro: 'img',
zone: 'img',
}
const SCOPE_PLUGIN = {
jd: [
async function runtimeMainPlugin () {
return {
name: 'runtime-main-plugin',
/* 其他生命周期 API */
configureWebpack (_, isServer) {
if (!isServer) {
return {
optimization: {
runtimeChunk: {
// Note: 修改入口名,OSS 不支持默认的 ~ 符号
name: entrypoint => `runtime-${entrypoint.name}`,
}
},
output: {
publicPath: `//storage.360buyimg.com/pubfree-bucket/taro-docs/${uniqueCommitId.latest()}/`
}
}
}
},
}
}
]
}
const siteConfig = {
title: 'Taro 文档' /* title for your website */,
tagline: 'Taro 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/QQ 小程序/H5/React Native 等应用。',
url: url[BASE_DOMAIN], /* your website url */
baseUrl: baseUrl[BASE_DOMAIN], /* base url for your project */
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
onDuplicateRoutes: 'warn',
favicon: require.resolve('./static/img/favicon.ico'),
organizationName: 'nervjs',
projectName: 'taro',
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
// sidebars file relative to website dir.
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://github.com/nervjs/taro-docs/edit/master/',
lastVersion: '3.x',
versions: {
current: {
label: '4.x',
}
}
},
blog: {
showReadingTime: true,
// Please change this to your repo.
editUrl: 'https://github.com/nervjs/taro-docs/edit/master/',
blogSidebarCount: 'ALL',
blogSidebarTitle: '全部'
},
theme: {
customCss: require.resolve('./static/css/custom.css'),
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
},
})
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
algolia: {
appId: 'BH4D9OD16A',
apiKey: '3f32982103f4e75dadd86900d26a9315', /* (github.com)taro:57b9948bff42bc0dbc6c219556fbae35, (netlify)taro_new:820a8e12c97e870d4e0785d52858230c */
contextualSearch: true,
indexName: 'taro-zone',
searchParameters: {
// facetFilters: [`version: ${versions[0]}`],
},
},
announcementBar: {
id: 'support_us', // Any value that will identify this message.
content:
'<div class="top_tip" role="alert">由凹凸实验室倾力打造的「Deco 设计稿一键生成多端代码」预览版正式上线啦,欢迎<a target="_blank" href="https://deco-preview.jd.com?from=taro-docs">免费试用</a>!</div>',
backgroundColor: '#f6ffed', // Defaults to `#fff`.
textColor: '#333333', // Defaults to `#000`.
isCloseable: true, // Defaults to `true`.
},
colorMode: {
defaultMode: 'light',
disableSwitch: false,
respectPrefersColorScheme: true,
},
docs: {
sidebar: {
hideable: true
}
},
footer: {
style: 'dark',
links: [
{
title: '文档',
items: [
{
label: '文档',
to: '/docs/',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Taro by O2 labs`,
},
navbar: {
hideOnScroll: false,
title: 'Taro',
logo: {
alt: 'Taro logo',
src: `${imgBaseUrl[BASE_DOMAIN]}/logo-taro.png`,
srcDark: `${imgBaseUrl[BASE_DOMAIN]}/logo-taro.png`
},
items: [
{
type: 'docsVersionDropdown',
position: 'left',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
{
to: '/versions',
label: '全部版本',
},
],
},
{
type: 'doc',
docId: 'README',
label: '文档',
position: 'left'
},
{
type: 'doc',
docId: 'components-desc',
label: '组件库',
position: 'left',
},
{
type: 'doc',
docId: 'apis/about/desc',
label: 'API',
position: 'left',
},
{
href: '/canIUse',
label: 'CanIUse',
position: 'left',
},
{
to: 'docs/guide',
activeBasePath: 'docs/guide',
activeBaseRegex: 'docs/guide',
label: '教程',
position: 'left',
},
{
to: 'blog',
label: '博客',
position: 'left',
},
{ href: 'https://github.com/NervJS/taro/issues', label: '问题反馈', position: 'left' },
{ href: 'https://deco-preview.jd.com?from=taro-docs', label: '设计稿生成代码', position: 'left' },
{
label: '生态系统',
position: 'right',
items:[
{ href: 'https://github.com/NervJS/taro/discussions', label: '论坛' },
{ href: 'https://taro-ext.jd.com', label: '物料市场' },
{ to: 'showcase', label: '案例' },
{ href: 'https://nutui.jd.com/#/', label: 'NutUI' },
{ href: 'https://taro-ui.jd.com', label: 'Taro UI' },
{ href: 'https://taro.jd.com/jdmp/index.html', label: '京东小程序' },
]
},
{
type: 'localeDropdown',
position: 'right',
},
{
href: 'https://github.com/nervjs/taro',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
},
prism: {
theme: require('prism-react-renderer/themes/github'),
darkTheme: require('prism-react-renderer/themes/dracula'),
}
}),
customFields: {
versions
},
scripts: [
{
src: 'https://storage.jd.com/taro-resource/tongji.js',
async: true
},
{
src: 'https://storage.jd.com/taro-docs/taro-doc-hotjar.js',
async: true
},
{
src: 'https://storage.360buyimg.com/quark-platform/sdk/ling-distribute-sdk-h5.0.7.0.js',
async: true
},
],
i18n: {
defaultLocale: 'zh-cn',
locales: ['zh-cn', 'en'],
localeConfigs: {
en: {
label: 'English',
direction: 'ltr',
},
'zh-cn':{
label: '中文',
direction: 'ltr',
},
},
},
plugins: [
[
'pwa',
{
debug: true,
offlineModeActivationStrategies: [
'appInstalled',
'standalone',
'queryString',
],
// swRegister: false,
swCustom: path.resolve(__dirname, 'src/sw.js'),
pwaHead: [
{
tagName: 'link',
rel: 'icon',
href: 'img/taro-logo_180.png',
},
{
tagName: 'link',
rel: 'manifest',
href: 'manifest.json',
},
{
tagName: 'meta',
name: 'theme-color',
content: 'rgb(0, 0, 194)',
},
{
tagName: 'meta',
name: 'apple-mobile-web-app-capable',
content: 'yes',
},
{
tagName: 'meta',
name: 'apple-mobile-web-app-status-bar-style',
content: '#000',
},
{
tagName: 'link',
rel: 'apple-touch-icon',
href: 'img/taro-logo_180.png',
},
{
tagName: 'link',
rel: 'mask-icon',
href: 'img/taro-logo_180.png',
color: 'rgb(62, 204, 94)',
},
{
tagName: 'meta',
name: 'msapplication-TileImage',
content: 'img/taro-logo_180.png',
},
{
tagName: 'meta',
name: 'msapplication-TileColor',
content: '#000',
},
],
},
],
],
webpack: {
jsLoader: (isServer) => ({
loader: require.resolve('swc-loader'),
options: {
jsc: {
baseUrl: baseUrl[BASE_DOMAIN],
parser: {
syntax: 'typescript',
tsx: true
},
target: 'es2017',
},
module: {
type: isServer ? 'commonjs' : 'es6',
}
},
}),
},
}
if (SCOPE_PLUGIN[BASE_DOMAIN]) {
siteConfig.plugins = siteConfig.plugins.concat(SCOPE_PLUGIN[BASE_DOMAIN])
}
module.exports = siteConfig