-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
docusaurus.config.js
316 lines (308 loc) · 9.85 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
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const path = require('path');
const fs = require('fs');
const yaml = require('js-yaml');
const i18n = require('./i18n');
const ArchivedVersions = require('./archivedVersions.json');
const JestThemeColor = '#15c213';
const crowdinConfig = yaml.load(
fs.readFileSync(path.resolve(__dirname, '../crowdin.yaml'), 'utf8')
);
const localeMapping = new Map(
Object.entries(crowdinConfig.languages_mapping.locale).map(
([translation, locale]) => [locale, translation]
)
);
/** @type {import('@docusaurus/types').Config} */
const config = {
i18n,
title: 'Jest',
titleDelimiter: '·',
tagline: '🃏 Delightful JavaScript Testing',
url: 'https://jestjs.io',
baseUrl: '/',
organizationName: 'facebook',
projectName: 'jest',
favicon: 'img/favicon/favicon.ico',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
presets: [
[
'@docusaurus/preset-classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
// homePageId: 'getting-started',
showLastUpdateAuthor: true,
showLastUpdateTime: true,
editUrl: ({locale, versionDocsDirPath, docPath}) => {
const translation =
locale === 'en' ? 'en' : localeMapping.get(locale) || locale;
if (translation !== 'en') {
return `https://crowdin.com/project/jest-v2/${translation}`;
}
return `https://github.com/jestjs/jest/edit/main/website/${versionDocsDirPath}/${docPath}`;
},
path: '../docs',
sidebarPath: path.resolve(__dirname, './sidebars.json'),
remarkPlugins: [
[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
require('docusaurus-remark-plugin-tab-blocks'),
],
},
blog: {
showReadingTime: true,
editUrl: 'https://github.com/jestjs/jest/tree/main/website/',
},
theme: {
customCss: [
path.resolve('src/css/docusaurusTheme.css'),
path.resolve('src/css/algoliaDocSearchTheme.css'),
path.resolve('src/components/v1/legacyCSS.css'),
path.resolve('static/css/custom.css'),
path.resolve('static/css/jest.css'),
require.resolve(
'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'
),
],
},
gtag: {
trackingID: 'UA-44373548-17',
},
pages: {
remarkPlugins: [
[require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
],
},
}),
],
],
plugins: [
[
'@docusaurus/plugin-client-redirects',
/** @type {import('@docusaurus/plugin-client-redirects').Options} */
({
// for legacy v1 Docusaurus site: /api.html => /api
fromExtensions: ['html'],
}),
],
[
'@docusaurus/plugin-pwa',
/** @type {import('@docusaurus/plugin-pwa').Options} */
({
pwaHead: [
{
tagName: 'link',
rel: 'icon',
href: 'img/jest.png',
},
{
tagName: 'link',
rel: 'manifest',
href: 'manifest.json',
},
{
tagName: 'meta',
name: 'theme-color',
content: '#FFF',
},
{
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/jest.png',
},
{
tagName: 'link',
rel: 'mask-icon',
href: 'img/jest.svg',
color: JestThemeColor,
},
{
tagName: 'meta',
name: 'msapplication-TileImage',
content: 'img/jest.png',
},
{
tagName: 'meta',
name: 'msapplication-TileColor',
content: '#000',
},
],
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
announcementBar: {
id: 'support_ukraine',
content:
'Support Ukraine 🇺🇦 <a target="_blank" rel="noopener noreferrer" href="https://opensource.facebook.com/support-ukraine"> Help Provide Humanitarian Aid to Ukraine</a>.',
backgroundColor: '#20232a',
textColor: '#fff',
isCloseable: false,
},
docs: {
sidebar: {
hideable: true,
},
},
navbar: {
title: 'Jest',
items: [
// left items
{
type: 'docsVersionDropdown',
position: 'left',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
...Object.entries(ArchivedVersions).map(
([versionName, versionUrl]) => ({
href: versionUrl,
label: versionName,
})
),
{
to: '/versions',
label: 'All versions',
},
],
},
// right items
{
label: 'Docs',
type: 'doc',
docId: 'getting-started',
position: 'right',
},
{
label: 'API',
type: 'doc',
docId: 'api',
position: 'right',
},
{
to: '/help',
label: 'Help',
position: 'right',
},
{to: 'blog', label: 'Blog', position: 'right'},
{type: 'localeDropdown', position: 'right'},
{
href: 'https://github.com/jestjs/jest',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
},
image: 'img/opengraph.png',
prism: {
additionalLanguages: ['bash', 'diff', 'json'],
theme: require('./src/prism/themeLight'),
darkTheme: require('./src/prism/themeDark'),
},
footer: {
style: 'dark',
links: [
{
title: 'Docs',
items: [
{
label: 'Getting Started',
to: '/docs/getting-started',
},
{
label: 'Guides',
to: '/docs/snapshot-testing',
},
{
label: 'API Reference',
to: '/docs/api',
},
],
},
{
title: 'Community',
items: [
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/jestjs',
},
{
label: 'Reactiflux',
href: 'https://www.reactiflux.com',
},
{
label: 'Twitter',
href: 'https://twitter.com/jestjs_',
},
],
},
{
title: 'More',
items: [
{
label: 'Blog',
to: '/blog',
},
{
label: 'GitHub',
href: 'https://github.com/jestjs/jest',
},
{
label: 'Twitter',
href: 'https://twitter.com/jestjs_',
},
],
},
{
title: 'Legal',
items: [
{
label: 'Privacy',
href: 'https://opensource.facebook.com/legal/privacy/',
},
{
label: 'Terms',
href: 'https://opensource.facebook.com/legal/terms/',
},
],
},
],
logo: {
// src: 'img/jest-outline.svg',
alt: 'OpenJS Foundation Logo',
src: 'img/openjs_foundation-logo-horizontal-color-dark_background.svg',
href: 'https://openjsf.org/',
},
copyright: `<p>Copyright <a href="https://openjsf.org">OpenJS Foundation</a> and Jest contributors. All rights reserved. The <a href="https://openjsf.org">OpenJS Foundation</a> has registered trademarks and uses trademarks. For a list of trademarks of the <a href="https://openjsf.org">OpenJS Foundation</a>, please see our <a href="https://trademark-policy.openjsf.org">Trademark Policy</a> and <a href="https://trademark-list.openjsf.org">Trademark List</a>. Trademarks and logos not indicated on the <a href="https://trademark-list.openjsf.org">list of OpenJS Foundation trademarks</a> are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.</p>
<p><a href="https://openjsf.org">The OpenJS Foundation</a> | <a href="https://terms-of-use.openjsf.org">Terms of Use</a> | <a href="https://privacy-policy.openjsf.org">Privacy Policy</a> | <a href="https://bylaws.openjsf.org">Bylaws</a> | <a href="https://code-of-conduct.openjsf.org">Code of Conduct</a> | <a href="https://trademark-policy.openjsf.org">Trademark Policy</a> | <a href="https://trademark-list.openjsf.org">Trademark List</a> | <a href="https://www.linuxfoundation.org/cookies">Cookie Policy</a></p>Built with Docusaurus.`,
},
algolia: {
indexName: 'jest-v2',
appId: 'HP439UUSOL',
apiKey: 'e5e670fd16f8f17caada79d6b0931682',
contextualSearch: true,
},
}),
};
module.exports = config;