-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdocusaurus.config.js
565 lines (557 loc) · 16.4 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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
require('dotenv').config()
const path = require('path')
import remarkEmbedder from '@remark-embedder/core'
const YouTubeTransformer = {
name: 'YouTubeTransformer',
shouldTransform(url) {
const ytEndpoints = [
{
schemes: [
'https://*.youtube.com/watch*',
'https://*.youtube.com/v/*',
'https://youtu.be/*',
'https://*.youtube.com/playlist?list=*',
'https://youtube.com/playlist?list=*',
'https://*.youtube.com/shorts*',
],
url: 'https://www.youtube.com/oembed',
discovery: true,
},
]
for (const endpoint of ytEndpoints) {
if (
endpoint.schemes?.some((scheme) =>
new RegExp(scheme.replace(/\*/g, '(.*)')).test(url),
)
) {
return true
}
}
return false
},
// default config function returns what it's given
getHTML(url, options = {}) {
function getVideoID(userInput) {
var res = userInput.match(
/^.*(?:(?:youtu.be\/)|(?:v\/)|(?:\/u\/\w\/)|(?:embed\/)|(?:watch\?))\??v?=?([^#\&\?]*).*/,
)
if (res) return res[1]
return false
}
const videoID = getVideoID(url)
return `<div style="width: ${options.width || '100%'}; margin: 0 ${
options.align || '0'
};"><div style="position: relative; padding-bottom: 56.25%; padding-top: 25px; height: 0;"><iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="https://www.youtube.com/embed/${videoID}"></iframe></div></div>`
},
}
/**
* Pinned version of the CLI to use for docs
* When bumping the version, add any new commands to the documents array
*/
const DVC_CLI_VERSION = 'v5.20.2' // auto updated by dvc cli release workflow
const VSCODE_EXTENSION_VERSION = 'v1.4.10' // auto updated by extension release workflow
const removeDocsSections = (content, sectionNames, headerIdentifier = '##') => {
let result = content
for (const sectionName of sectionNames) {
const regex = new RegExp(
`${headerIdentifier} ${sectionName}[\\s\\S]*?(?=## |#$|$)`,
'g',
)
result = result.replace(regex, '')
}
return result
}
/**
* @type {Partial<import('@docusaurus/types').DocusaurusConfig>}
*/
const config = {
clientModules: [
require.resolve('./src/modules/analyticsModule.js'),
require.resolve('./src/modules/rudderstackClientModule.js'),
],
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
plugins: [
() => {
// ...
return {
name: 'tailwind',
configurePostCss(postcssOptions) {
postcssOptions.plugins.push(
require('postcss-import'),
require('tailwindcss'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009',
},
stage: 4,
}),
)
return postcssOptions
},
}
},
path.resolve(__dirname, 'plugins', 'custom-gtm'),
path.resolve(__dirname, 'plugins', 'custom-beamer'),
[
'docusaurus-plugin-remote-content',
{
name: 'cli',
sourceBaseUrl: `https://raw.githubusercontent.com/DevCycleHQ/cli/${DVC_CLI_VERSION}`,
outDir: 'docs/cli',
documents: [
'README.md',
'docs/alias.md',
'docs/autocomplete.md',
'docs/cleanup.md',
'docs/diff.md',
'docs/environments.md',
'docs/features.md',
'docs/generate.md',
'docs/help.md',
'docs/identity.md',
'docs/keys.md',
'docs/login.md',
'docs/logout.md',
'docs/organizations.md',
'docs/overrides.md',
'docs/projects.md',
'docs/repo.md',
'docs/status.md',
'docs/targeting.md',
'docs/usages.md',
'docs/variables.md',
'docs/variations.md',
],
performCleanup: true,
modifyContent: (filename, content) => {
if (filename.includes('README')) {
return {
// reduce headers to use with table of contents
content: content.replace(/#\s/g, '## '),
}
}
return undefined
},
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'vscode-extension',
sourceBaseUrl: `https://raw.githubusercontent.com/DevCycleHQ/vscode-extension/${VSCODE_EXTENSION_VERSION}`,
outDir: 'docs/integrations/vscode-extension',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => {
if (filename.includes('README')) {
const noTitle = content.replace(
/# [\s\S]*?##/,
'# DevCycle VSCode Extension \n##',
)
return {
content: removeDocsSections(noTitle, [
'About DevCycle',
'Documentation',
'Sign Up for DevCycle',
'Contributing',
]),
}
}
return undefined
},
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'github.feature-usage-action',
sourceBaseUrl:
'https://raw.githubusercontent.com/DevCycleHQ/feature-flag-code-usage-action/main/',
outDir: 'docs/integrations/github/feature-usage-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# GitHub: Feature Flag Code Usages \n' +
'Get the integration on the [GitHub Marketplace](https://github.com/marketplace/actions/devcycle-feature-flag-code-usages)\n' +
content,
}),
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'github.pr-insights-action',
sourceBaseUrl:
'https://raw.githubusercontent.com/DevCycleHQ/feature-flag-pr-insights-action/main/',
outDir: 'docs/integrations/github/pr-insights-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# GitHub: Feature Flag Change Insights on Pull Request \n' +
'Get the integration on the [GitHub Marketplace](https://github.com/marketplace/actions/devcycle-feature-flag-insights-for-pull-requests)\n' +
content,
}),
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'bitbucket.feature-usage-action',
sourceBaseUrl:
'https://bitbucket.org/devcyclehq/devcycle-code-refs-pipe/raw/main/',
outDir: 'docs/integrations/bitbucket/feature-usage-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# Bitbucket: Feature Flag Code Usages\n' +
'Get the integration on the [Bitbucket Marketplace](https://bitbucket.org/product/features/pipelines/integrations?&p=devcyclehq/devcycle-code-refs-pipe)\n' +
content,
}),
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'bitbucket.pr-insights-action',
sourceBaseUrl:
'https://bitbucket.org/devcyclehq/devcycle-pr-insights-pipe/raw/main/',
outDir: 'docs/integrations/bitbucket/pr-insights-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# Bitbucket: Feature Flag Change Insights on Pull Request\n' +
'Get the integration on the [Bitbucket Marketplace](https://bitbucket.org/product/features/pipelines/integrations?&p=devcyclehq/devcycle-pr-insights-pipe)\n' +
content,
}),
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'gitlab.feature-usage-action',
sourceBaseUrl:
'https://gitlab.com/devcycle/devcycle-usages-ci-cd/-/raw/main/',
outDir: 'docs/integrations/gitlab/feature-usage-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# GitLab: Feature Flag Code Usages \n' +
'Get the integration here: https://gitlab.com/devcycle/devcycle-usages-ci-cd\n' +
content,
}),
},
],
[
'docusaurus-plugin-remote-content',
{
name: 'gitlab.pr-insights-action',
sourceBaseUrl:
'https://gitlab.com/devcycle/devcycle-pr-insights-ci-cd/-/raw/main/',
outDir: 'docs/integrations/gitlab/pr-insights-action',
documents: ['README.md'],
performCleanup: true,
modifyContent: (filename, content) => ({
content:
'# GitLab: Feature Flag Change Insights on Merge Request\n' +
'Get the integration here: https://gitlab.com/devcycle/devcycle-pr-insights-ci-cd\n' +
content,
}),
},
],
],
presets: [
[
'@docusaurus/preset-classic',
{
debug: Boolean(process.env.DEBUG || process.env.CI),
docs: {
editUrl: ({ versionDocsDirPath, docPath }) =>
`https://github.com/devcyclehq/devcycle-docs/edit/main/${versionDocsDirPath}/${docPath}`,
showLastUpdateAuthor: false,
showLastUpdateTime: true,
editCurrentVersion: true,
sidebarPath: require.resolve('./sidebars.js'),
remarkPlugins: [
[remarkEmbedder, { transformers: [[YouTubeTransformer]] }],
require('remark-docusaurus-tabs'),
],
rehypePlugins: [],
routeBasePath: '/',
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
},
theme: {
customCss: [require.resolve('./src/css/custom.css')],
},
},
],
[
'redocusaurus',
{
debug: Boolean(process.env.DEBUG || process.env.CI),
specs: [
{
id: 'management-api',
spec: 'https://api.devcycle.com/swagger.json',
route: '/management-api/',
},
{
id: 'bucketing-api',
spec: 'bucketing-api.yaml',
route: '/bucketing-api/',
},
],
theme: {
primaryColor: '#365EDA',
redocOptions: { hideDownloadButton: false },
},
},
],
],
/** ************ Rest of your Docusaurus Config *********** */
title: 'DevCycle Docs',
tagline: 'DevCycle Feature Management and Experimentation',
customFields: {
meta: {
description:
'The DevCycle documentation site includes guides and API documentation for the complete platform including the management dashboard, management APIs, SDKs, and more. If you need help along the way feel free to reach out to support and if you don’t have an account yet, you can create a free account now.',
},
DEVCYCLE_CLIENT_SDK_KEY: process.env.DEVCYCLE_CLIENT_SDK_KEY,
},
url:
process.env.VERCEL_ENV === 'production'
? 'https://docs.devcycle.com'
: process.env.VERCEL_URL
? 'https://' + process.env.VERCEL_URL
: 'http://localhost:3000',
baseUrl: '/',
favicon: 'devcycle_favicon.svg',
scripts: [
{
src: 'https://use.fontawesome.com/releases/v5.15.4/js/all.js',
async: true,
},
],
themeConfig: {
// announcementBar: {
// id: 'support_us',
// content:
// 'Ready to start feature flagging? Sign-up for a free <a target="_blank" rel="noopener noreferrer" href="https://devcycle.com">DevCycle account</a> today 🏳️',
// backgroundColor: 'rgb(17 24 39)',
// textColor: '#FFFFFF',
// isCloseable: false,
// },
image: 'devcycle_card.png',
docs: {
sidebar: {
autoCollapseCategories: true,
hideable: true,
},
},
prism: {
additionalLanguages: [
'ruby',
'go',
'swift',
'kotlin',
'java',
'clike',
'scala',
'hcl',
'yaml',
'csharp',
'dart',
'python',
// Leave php disabled until this issue is fixed upstream: https://github.com/PrismJS/prism/issues/2769
//'php'
],
},
algolia: {
appId: '6TW93YPS4X',
apiKey: '2a9dbde35586f5ae29571b19dacc71c6', // Public API key: it is safe to commit it
indexName: 'prod_DEVCYCLE_DOCS',
contextualSearch: true,
},
navbar: {
logo: {
alt: 'DevCycle Logo',
src: 'devcycle-docs-full-colour.svg',
srcDark: 'devcycle-docs-white.svg',
},
items: [
{
type: 'docSidebar',
sidebarId: 'home',
position: 'left',
collapse: 'false',
label: 'Home',
},
{
type: 'docSidebar',
sidebarId: 'sdks',
position: 'left',
collapse: 'false',
label: 'SDKs',
},
{
type: 'dropdown',
label: 'APIs',
position: 'left',
items: [
{
label: 'Management API',
to: '/management-api/',
},
{
label: 'Bucketing API',
to: '/bucketing-api/',
},
],
},
{
type: 'doc',
docId: 'integrations/index',
position: 'left',
collapse: 'false',
label: 'Integrations',
},
{
type: 'dropdown',
label: 'CLI',
position: 'left',
items: [
{
label: 'Reference Docs',
to: '/cli/'
},
{
label: 'User Guides',
to: '/cli-guides/'
}
]
},
{
label: 'Best Practices',
to: '/best-practices/',
},
{
type: 'dropdown',
label: 'Community',
position: 'left',
items: [
{
label: 'Calendar',
to: '/community/calendar',
},
{
href: 'https://blog.devcycle.com',
label: 'Blog',
target: '_blank',
rel: null,
},
{
href: 'https://discord.gg/8uEqSsRKy5',
label: 'Discord',
target: '_blank',
rel: null,
},
],
},
{
type: 'search',
position: 'right',
},
// {
// href: 'https://devcycle.com/contact/request-demo',
// position: 'right',
// label: 'Book a Demo',
// className: 'navbar-book-demo',
// },
{
href: 'https://app.devcycle.com/?isSignUp=true',
position: 'right',
className: 'header-signup-link',
label: 'Sign Up',
},
{
href: 'https://discord.gg/8uEqSsRKy5',
position: 'right',
className: 'header-discord-link',
'aria-label': 'Discord',
},
{
href: '#',
position: 'right',
className: 'header-beamer-link',
'aria-label': 'Beamer',
},
],
},
footer: {
logo: {
alt: 'DevCycle Logo',
src: 'togglebot.png',
},
style: 'dark',
links: [
{
title: 'Resources',
items: [
{
label: 'DevCycle home',
href: 'https://Devcycle.com',
},
{
label: 'Dashboard',
href: 'https://app.devcycle.com',
},
{
label: 'Github',
href: 'https://github.com/devcyclehq',
},
{
label: 'Discord',
href: 'https://discord.gg/8uEqSsRKy5',
},
],
},
{
title: 'More',
items: [
{
label: 'Blog',
href: 'https://blog.devcycle.com',
},
// {
// label: 'Status',
// href: 'https://status.DevCycle.com/'
// },
],
},
{
title: 'Community',
items: [
{
label: 'Twitter',
href: 'https://twitter.com/devcyclehq',
},
{
label: 'Discord',
href: 'https://discord.gg/8uEqSsRKy5',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} DevCycle.`,
},
},
}
module.exports = config