@docusaurus/plugin-content-docs 2.0.0-beta.12faed89d → 2.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/.tsbuildinfo +1 -1
- package/lib/categoryGeneratedIndex.d.ts +12 -0
- package/lib/categoryGeneratedIndex.js +37 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +12 -34
- package/lib/client/docsClientUtils.d.ts +0 -3
- package/lib/client/docsClientUtils.js +19 -22
- package/lib/docFrontMatter.d.ts +1 -1
- package/lib/docFrontMatter.js +7 -3
- package/lib/docs.d.ts +25 -3
- package/lib/docs.js +125 -41
- package/lib/globalData.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +100 -131
- package/lib/lastUpdate.js +8 -9
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.js +2 -2
- package/lib/numberPrefix.d.ts +1 -1
- package/lib/options.d.ts +3 -3
- package/lib/options.js +48 -11
- package/lib/props.d.ts +7 -2
- package/lib/props.js +60 -8
- package/lib/routes.d.ts +27 -0
- package/lib/routes.js +105 -0
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +5 -2
- package/lib/sidebars/generator.js +216 -0
- package/lib/sidebars/index.d.ts +15 -0
- package/lib/sidebars/index.js +73 -0
- package/lib/sidebars/normalization.d.ts +14 -0
- package/lib/sidebars/normalization.js +77 -0
- package/lib/sidebars/processor.d.ts +18 -0
- package/lib/sidebars/processor.js +85 -0
- package/lib/sidebars/types.d.ts +127 -0
- package/lib/sidebars/types.js +8 -0
- package/lib/sidebars/utils.d.ts +35 -0
- package/lib/sidebars/utils.js +228 -0
- package/lib/sidebars/validation.d.ts +10 -0
- package/lib/sidebars/validation.js +138 -0
- package/lib/slug.d.ts +4 -3
- package/lib/slug.js +27 -15
- package/lib/tags.d.ts +8 -0
- package/lib/tags.js +20 -0
- package/lib/theme/hooks/useDocs.js +21 -21
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +71 -29
- package/lib/types.d.ts +52 -63
- package/lib/versions.d.ts +3 -3
- package/lib/versions.js +41 -22
- package/package.json +20 -20
- package/src/__tests__/__fixtures__/simple-site/docs/_partials/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/_partials/subfolder/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/_somePartial.md +3 -0
- package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +5 -0
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +2 -0
- package/src/__tests__/__fixtures__/simple-site/sidebars.json +15 -1
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +1 -0
- package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +6 -0
- package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/subfolder/somePartial.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_somePartial.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +3 -0
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +2 -2
- package/src/__tests__/__snapshots__/cli.test.ts.snap +48 -73
- package/src/__tests__/__snapshots__/docs.test.ts.snap +140 -0
- package/src/__tests__/__snapshots__/index.test.ts.snap +745 -97
- package/src/__tests__/__snapshots__/translations.test.ts.snap +45 -15
- package/src/__tests__/cli.test.ts +15 -11
- package/src/__tests__/docFrontMatter.test.ts +160 -45
- package/src/__tests__/docs.test.ts +311 -150
- package/src/__tests__/index.test.ts +108 -66
- package/src/__tests__/lastUpdate.test.ts +1 -1
- package/src/__tests__/options.test.ts +48 -3
- package/src/__tests__/props.test.ts +62 -0
- package/src/__tests__/slug.test.ts +127 -20
- package/src/__tests__/translations.test.ts +7 -1
- package/src/__tests__/versions.test.ts +73 -70
- package/src/categoryGeneratedIndex.ts +57 -0
- package/src/cli.ts +8 -41
- package/src/client/docsClientUtils.ts +14 -26
- package/{types.d.ts → src/deps.d.ts} +0 -0
- package/src/docFrontMatter.ts +9 -4
- package/src/docs.ts +158 -32
- package/src/globalData.ts +6 -1
- package/src/index.ts +125 -169
- package/src/lastUpdate.ts +10 -13
- package/src/markdown/index.ts +8 -12
- package/src/numberPrefix.ts +5 -3
- package/src/options.ts +59 -14
- package/src/plugin-content-docs.d.ts +173 -40
- package/src/props.ts +90 -15
- package/src/routes.ts +173 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-category.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-collapsed.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-link.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-unknown-type.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars-wrong-field.json +0 -0
- package/src/{__tests__ → sidebars/__tests__}/__fixtures__/sidebars/sidebars.json +0 -0
- package/src/{__tests__/__snapshots__/sidebars.test.ts.snap → sidebars/__tests__/__snapshots__/index.test.ts.snap} +36 -6
- package/src/{__tests__/sidebarItemsGenerator.test.ts → sidebars/__tests__/generator.test.ts} +143 -18
- package/src/sidebars/__tests__/index.test.ts +204 -0
- package/src/sidebars/__tests__/processor.test.ts +237 -0
- package/src/sidebars/__tests__/utils.test.ts +695 -0
- package/src/sidebars/__tests__/validation.test.ts +105 -0
- package/src/sidebars/generator.ts +310 -0
- package/src/sidebars/index.ts +94 -0
- package/src/sidebars/normalization.ts +112 -0
- package/src/sidebars/processor.ts +154 -0
- package/src/sidebars/types.ts +211 -0
- package/src/sidebars/utils.ts +329 -0
- package/src/sidebars/validation.ts +168 -0
- package/src/slug.ts +32 -17
- package/src/tags.ts +19 -0
- package/src/translations.ts +103 -47
- package/src/types.ts +64 -107
- package/src/versions.ts +59 -25
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -43
- package/lib/sidebars.js +0 -320
- package/src/__tests__/sidebars.test.ts +0 -639
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -522
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
9
|
-
|
|
10
8
|
import path from 'path';
|
|
11
9
|
import {isMatch} from 'picomatch';
|
|
12
10
|
import commander from 'commander';
|
|
@@ -16,25 +14,23 @@ import fs from 'fs-extra';
|
|
|
16
14
|
import pluginContentDocs from '../index';
|
|
17
15
|
import {loadContext} from '@docusaurus/core/src/server/index';
|
|
18
16
|
import {applyConfigureWebpack} from '@docusaurus/core/src/webpack/utils';
|
|
19
|
-
import {RouteConfig} from '@docusaurus/types';
|
|
20
|
-
import {posixPath} from '@docusaurus/utils';
|
|
17
|
+
import type {RouteConfig} from '@docusaurus/types';
|
|
18
|
+
import {posixPath, DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
|
|
21
19
|
import {sortConfig} from '@docusaurus/core/src/server/plugins';
|
|
22
|
-
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
|
|
23
20
|
|
|
24
21
|
import * as cliDocs from '../cli';
|
|
25
22
|
import {OptionsSchema} from '../options';
|
|
26
23
|
import {normalizePluginOptions} from '@docusaurus/utils-validation';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
LoadedVersion,
|
|
24
|
+
import type {DocMetadata, LoadedVersion} from '../types';
|
|
25
|
+
import type {
|
|
30
26
|
SidebarItem,
|
|
31
27
|
SidebarItemsGeneratorOption,
|
|
32
28
|
SidebarItemsGeneratorOptionArgs,
|
|
33
|
-
} from '../types';
|
|
29
|
+
} from '../sidebars/types';
|
|
34
30
|
import {toSidebarsProp} from '../props';
|
|
35
31
|
|
|
36
32
|
import {validate} from 'webpack';
|
|
37
|
-
import {DefaultSidebarItemsGenerator} from '../
|
|
33
|
+
import {DefaultSidebarItemsGenerator} from '../sidebars/generator';
|
|
38
34
|
import {DisabledSidebars} from '../sidebars';
|
|
39
35
|
|
|
40
36
|
function findDocById(version: LoadedVersion, unversionedId: string) {
|
|
@@ -60,6 +56,7 @@ const defaultDocMetadata: Partial<DocMetadata> = {
|
|
|
60
56
|
lastUpdatedAt: undefined,
|
|
61
57
|
lastUpdatedBy: undefined,
|
|
62
58
|
formattedLastUpdatedAt: undefined,
|
|
59
|
+
tags: [],
|
|
63
60
|
};
|
|
64
61
|
|
|
65
62
|
const createFakeActions = (contentDir: string) => {
|
|
@@ -249,7 +246,6 @@ describe('simple website', () => {
|
|
|
249
246
|
normalizePluginOptions(OptionsSchema, {
|
|
250
247
|
path: 'docs',
|
|
251
248
|
sidebarPath,
|
|
252
|
-
homePageId: 'hello',
|
|
253
249
|
}),
|
|
254
250
|
);
|
|
255
251
|
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
|
@@ -270,6 +266,8 @@ describe('simple website', () => {
|
|
|
270
266
|
expect(mock).toHaveBeenCalledWith('1.0.0', siteDir, DEFAULT_PLUGIN_ID, {
|
|
271
267
|
path: 'docs',
|
|
272
268
|
sidebarPath,
|
|
269
|
+
sidebarCollapsed: true,
|
|
270
|
+
sidebarCollapsible: true,
|
|
273
271
|
});
|
|
274
272
|
mock.mockRestore();
|
|
275
273
|
});
|
|
@@ -337,7 +335,6 @@ describe('simple website', () => {
|
|
|
337
335
|
id: 'foo/baz',
|
|
338
336
|
unversionedId: 'foo/baz',
|
|
339
337
|
sourceDirName: 'foo',
|
|
340
|
-
isDocsHomePage: false,
|
|
341
338
|
permalink: '/docs/foo/bazSlug.html',
|
|
342
339
|
slug: '/foo/bazSlug.html',
|
|
343
340
|
previous: {
|
|
@@ -345,10 +342,11 @@ describe('simple website', () => {
|
|
|
345
342
|
permalink: '/docs/foo/bar',
|
|
346
343
|
},
|
|
347
344
|
next: {
|
|
348
|
-
title: '
|
|
349
|
-
permalink: '/docs/',
|
|
345
|
+
title: 'rootAbsoluteSlug',
|
|
346
|
+
permalink: '/docs/rootAbsoluteSlug',
|
|
350
347
|
},
|
|
351
348
|
sidebar: 'docs',
|
|
349
|
+
sidebarPosition: undefined,
|
|
352
350
|
source: path.posix.join(
|
|
353
351
|
'@site',
|
|
354
352
|
posixPath(path.relative(siteDir, currentVersion.contentPath)),
|
|
@@ -362,7 +360,23 @@ describe('simple website', () => {
|
|
|
362
360
|
title: 'baz',
|
|
363
361
|
slug: 'bazSlug.html',
|
|
364
362
|
pagination_label: 'baz pagination_label',
|
|
363
|
+
tags: [
|
|
364
|
+
'tag 1',
|
|
365
|
+
'tag-1', // This one will be de-duplicated as it would lead to the same permalink as the first
|
|
366
|
+
{label: 'tag 2', permalink: 'tag2-custom-permalink'},
|
|
367
|
+
],
|
|
365
368
|
},
|
|
369
|
+
|
|
370
|
+
tags: [
|
|
371
|
+
{
|
|
372
|
+
label: 'tag 1',
|
|
373
|
+
permalink: '/docs/tags/tag-1',
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
label: 'tag 2',
|
|
377
|
+
permalink: '/docs/tags/tag2-custom-permalink',
|
|
378
|
+
},
|
|
379
|
+
],
|
|
366
380
|
});
|
|
367
381
|
|
|
368
382
|
expect(findDocById(currentVersion, 'hello')).toEqual({
|
|
@@ -371,12 +385,11 @@ describe('simple website', () => {
|
|
|
371
385
|
id: 'hello',
|
|
372
386
|
unversionedId: 'hello',
|
|
373
387
|
sourceDirName: '.',
|
|
374
|
-
isDocsHomePage: true,
|
|
375
388
|
permalink: '/docs/',
|
|
376
389
|
slug: '/',
|
|
377
390
|
previous: {
|
|
378
|
-
title: '
|
|
379
|
-
permalink: '/docs/
|
|
391
|
+
title: 'My heading as title',
|
|
392
|
+
permalink: '/docs/headingAsTitle',
|
|
380
393
|
},
|
|
381
394
|
sidebar: 'docs',
|
|
382
395
|
source: path.posix.join(
|
|
@@ -390,7 +403,19 @@ describe('simple website', () => {
|
|
|
390
403
|
id: 'hello',
|
|
391
404
|
title: 'Hello, World !',
|
|
392
405
|
sidebar_label: 'Hello sidebar_label',
|
|
406
|
+
slug: '/',
|
|
407
|
+
tags: ['tag-1', 'tag 3'],
|
|
393
408
|
},
|
|
409
|
+
tags: [
|
|
410
|
+
{
|
|
411
|
+
label: 'tag-1',
|
|
412
|
+
permalink: '/docs/tags/tag-1',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
label: 'tag 3',
|
|
416
|
+
permalink: '/docs/tags/tag-3',
|
|
417
|
+
},
|
|
418
|
+
],
|
|
394
419
|
});
|
|
395
420
|
|
|
396
421
|
expect(getDocById(currentVersion, 'foo/bar')).toEqual({
|
|
@@ -399,7 +424,6 @@ describe('simple website', () => {
|
|
|
399
424
|
id: 'foo/bar',
|
|
400
425
|
unversionedId: 'foo/bar',
|
|
401
426
|
sourceDirName: 'foo',
|
|
402
|
-
isDocsHomePage: false,
|
|
403
427
|
next: {
|
|
404
428
|
title: 'baz pagination_label',
|
|
405
429
|
permalink: '/docs/foo/bazSlug.html',
|
|
@@ -451,7 +475,6 @@ describe('versioned website', () => {
|
|
|
451
475
|
normalizePluginOptions(OptionsSchema, {
|
|
452
476
|
routeBasePath,
|
|
453
477
|
sidebarPath,
|
|
454
|
-
homePageId: 'hello',
|
|
455
478
|
}),
|
|
456
479
|
);
|
|
457
480
|
const pluginContentDir = path.join(context.generatedFilesDir, plugin.name);
|
|
@@ -478,6 +501,8 @@ describe('versioned website', () => {
|
|
|
478
501
|
expect(mock).toHaveBeenCalledWith('2.0.0', siteDir, DEFAULT_PLUGIN_ID, {
|
|
479
502
|
path: routeBasePath,
|
|
480
503
|
sidebarPath,
|
|
504
|
+
sidebarCollapsed: true,
|
|
505
|
+
sidebarCollapsible: true,
|
|
481
506
|
});
|
|
482
507
|
mock.mockRestore();
|
|
483
508
|
});
|
|
@@ -545,12 +570,8 @@ describe('versioned website', () => {
|
|
|
545
570
|
const {siteDir, plugin, pluginContentDir} = await loadSite();
|
|
546
571
|
const content = await plugin.loadContent!();
|
|
547
572
|
expect(content.loadedVersions.length).toEqual(4);
|
|
548
|
-
const [
|
|
549
|
-
|
|
550
|
-
version101,
|
|
551
|
-
version100,
|
|
552
|
-
versionWithSlugs,
|
|
553
|
-
] = content.loadedVersions;
|
|
573
|
+
const [currentVersion, version101, version100, versionWithSlugs] =
|
|
574
|
+
content.loadedVersions;
|
|
554
575
|
|
|
555
576
|
// foo/baz.md only exists in version -1.0.0
|
|
556
577
|
expect(findDocById(currentVersion, 'foo/baz')).toBeUndefined();
|
|
@@ -562,7 +583,6 @@ describe('versioned website', () => {
|
|
|
562
583
|
id: 'foo/bar',
|
|
563
584
|
unversionedId: 'foo/bar',
|
|
564
585
|
sourceDirName: 'foo',
|
|
565
|
-
isDocsHomePage: false,
|
|
566
586
|
permalink: '/docs/next/foo/barSlug',
|
|
567
587
|
slug: '/foo/barSlug',
|
|
568
588
|
source: path.posix.join(
|
|
@@ -575,6 +595,11 @@ describe('versioned website', () => {
|
|
|
575
595
|
description: 'This is next version of bar.',
|
|
576
596
|
frontMatter: {
|
|
577
597
|
slug: 'barSlug',
|
|
598
|
+
tags: [
|
|
599
|
+
'barTag 1',
|
|
600
|
+
'barTag-2',
|
|
601
|
+
{label: 'barTag 3', permalink: 'barTag-3-permalink'},
|
|
602
|
+
],
|
|
578
603
|
},
|
|
579
604
|
version: 'current',
|
|
580
605
|
sidebar: 'docs',
|
|
@@ -582,13 +607,42 @@ describe('versioned website', () => {
|
|
|
582
607
|
title: 'hello',
|
|
583
608
|
permalink: '/docs/next/',
|
|
584
609
|
},
|
|
610
|
+
tags: [
|
|
611
|
+
{label: 'barTag 1', permalink: '/docs/next/tags/bar-tag-1'},
|
|
612
|
+
{label: 'barTag-2', permalink: '/docs/next/tags/bar-tag-2'},
|
|
613
|
+
{label: 'barTag 3', permalink: '/docs/next/tags/barTag-3-permalink'},
|
|
614
|
+
],
|
|
585
615
|
});
|
|
616
|
+
expect(getDocById(version101, 'foo/bar')).toEqual({
|
|
617
|
+
...defaultDocMetadata,
|
|
618
|
+
id: 'version-1.0.1/foo/bar',
|
|
619
|
+
unversionedId: 'foo/bar',
|
|
620
|
+
sourceDirName: 'foo',
|
|
621
|
+
permalink: '/docs/foo/bar',
|
|
622
|
+
slug: '/foo/bar',
|
|
623
|
+
source: path.posix.join(
|
|
624
|
+
'@site',
|
|
625
|
+
posixPath(path.relative(siteDir, version101.contentPath)),
|
|
626
|
+
'foo',
|
|
627
|
+
'bar.md',
|
|
628
|
+
),
|
|
629
|
+
title: 'bar',
|
|
630
|
+
description: 'Bar 1.0.1 !',
|
|
631
|
+
frontMatter: {},
|
|
632
|
+
version: '1.0.1',
|
|
633
|
+
sidebar: 'VersionedSideBarNameDoesNotMatter/docs',
|
|
634
|
+
next: {
|
|
635
|
+
title: 'hello',
|
|
636
|
+
permalink: '/docs/',
|
|
637
|
+
},
|
|
638
|
+
tags: [],
|
|
639
|
+
});
|
|
640
|
+
|
|
586
641
|
expect(getDocById(currentVersion, 'hello')).toEqual({
|
|
587
642
|
...defaultDocMetadata,
|
|
588
643
|
id: 'hello',
|
|
589
644
|
unversionedId: 'hello',
|
|
590
645
|
sourceDirName: '.',
|
|
591
|
-
isDocsHomePage: true,
|
|
592
646
|
permalink: '/docs/next/',
|
|
593
647
|
slug: '/',
|
|
594
648
|
source: path.posix.join(
|
|
@@ -598,7 +652,9 @@ describe('versioned website', () => {
|
|
|
598
652
|
),
|
|
599
653
|
title: 'hello',
|
|
600
654
|
description: 'Hello next !',
|
|
601
|
-
frontMatter: {
|
|
655
|
+
frontMatter: {
|
|
656
|
+
slug: '/',
|
|
657
|
+
},
|
|
602
658
|
version: 'current',
|
|
603
659
|
sidebar: 'docs',
|
|
604
660
|
previous: {
|
|
@@ -611,7 +667,6 @@ describe('versioned website', () => {
|
|
|
611
667
|
id: 'version-1.0.1/hello',
|
|
612
668
|
unversionedId: 'hello',
|
|
613
669
|
sourceDirName: '.',
|
|
614
|
-
isDocsHomePage: true,
|
|
615
670
|
permalink: '/docs/',
|
|
616
671
|
slug: '/',
|
|
617
672
|
source: path.posix.join(
|
|
@@ -621,9 +676,11 @@ describe('versioned website', () => {
|
|
|
621
676
|
),
|
|
622
677
|
title: 'hello',
|
|
623
678
|
description: 'Hello 1.0.1 !',
|
|
624
|
-
frontMatter: {
|
|
679
|
+
frontMatter: {
|
|
680
|
+
slug: '/',
|
|
681
|
+
},
|
|
625
682
|
version: '1.0.1',
|
|
626
|
-
sidebar: '
|
|
683
|
+
sidebar: 'VersionedSideBarNameDoesNotMatter/docs',
|
|
627
684
|
previous: {
|
|
628
685
|
title: 'bar',
|
|
629
686
|
permalink: '/docs/foo/bar',
|
|
@@ -634,7 +691,6 @@ describe('versioned website', () => {
|
|
|
634
691
|
id: 'version-1.0.0/foo/baz',
|
|
635
692
|
unversionedId: 'foo/baz',
|
|
636
693
|
sourceDirName: 'foo',
|
|
637
|
-
isDocsHomePage: false,
|
|
638
694
|
permalink: '/docs/1.0.0/foo/baz',
|
|
639
695
|
slug: '/foo/baz',
|
|
640
696
|
source: path.posix.join(
|
|
@@ -711,13 +767,8 @@ describe('versioned website (community)', () => {
|
|
|
711
767
|
}
|
|
712
768
|
|
|
713
769
|
test('extendCli - docsVersion', async () => {
|
|
714
|
-
const {
|
|
715
|
-
|
|
716
|
-
routeBasePath,
|
|
717
|
-
sidebarPath,
|
|
718
|
-
pluginId,
|
|
719
|
-
plugin,
|
|
720
|
-
} = await loadSite();
|
|
770
|
+
const {siteDir, routeBasePath, sidebarPath, pluginId, plugin} =
|
|
771
|
+
await loadSite();
|
|
721
772
|
const mock = jest
|
|
722
773
|
.spyOn(cliDocs, 'cliDocsVersionCommand')
|
|
723
774
|
.mockImplementation();
|
|
@@ -729,6 +780,8 @@ describe('versioned website (community)', () => {
|
|
|
729
780
|
expect(mock).toHaveBeenCalledWith('2.0.0', siteDir, pluginId, {
|
|
730
781
|
path: routeBasePath,
|
|
731
782
|
sidebarPath,
|
|
783
|
+
sidebarCollapsed: true,
|
|
784
|
+
sidebarCollapsible: true,
|
|
732
785
|
});
|
|
733
786
|
mock.mockRestore();
|
|
734
787
|
});
|
|
@@ -785,7 +838,6 @@ describe('versioned website (community)', () => {
|
|
|
785
838
|
id: 'team',
|
|
786
839
|
unversionedId: 'team',
|
|
787
840
|
sourceDirName: '.',
|
|
788
|
-
isDocsHomePage: false,
|
|
789
841
|
permalink: '/community/next/team',
|
|
790
842
|
slug: '/team',
|
|
791
843
|
source:
|
|
@@ -801,7 +853,6 @@ describe('versioned website (community)', () => {
|
|
|
801
853
|
id: 'version-1.0.0/team',
|
|
802
854
|
unversionedId: 'team',
|
|
803
855
|
sourceDirName: '.',
|
|
804
|
-
isDocsHomePage: false,
|
|
805
856
|
permalink: '/community/team',
|
|
806
857
|
slug: '/team',
|
|
807
858
|
source: path.posix.join(
|
|
@@ -843,7 +894,6 @@ describe('site with doc label', () => {
|
|
|
843
894
|
normalizePluginOptions(OptionsSchema, {
|
|
844
895
|
path: 'docs',
|
|
845
896
|
sidebarPath,
|
|
846
|
-
homePageId: 'hello-1',
|
|
847
897
|
}),
|
|
848
898
|
);
|
|
849
899
|
|
|
@@ -907,6 +957,7 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
907
957
|
type: 'category',
|
|
908
958
|
label: 'Guides',
|
|
909
959
|
collapsed: true,
|
|
960
|
+
collapsible: true,
|
|
910
961
|
items: [
|
|
911
962
|
{
|
|
912
963
|
type: 'doc',
|
|
@@ -938,6 +989,7 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
938
989
|
type: 'category',
|
|
939
990
|
label: 'API (label from _category_.json)',
|
|
940
991
|
collapsed: true,
|
|
992
|
+
collapsible: true,
|
|
941
993
|
items: [
|
|
942
994
|
{
|
|
943
995
|
type: 'doc',
|
|
@@ -947,6 +999,7 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
947
999
|
type: 'category',
|
|
948
1000
|
label: 'Core APIs',
|
|
949
1001
|
collapsed: true,
|
|
1002
|
+
collapsible: true,
|
|
950
1003
|
items: [
|
|
951
1004
|
{
|
|
952
1005
|
type: 'doc',
|
|
@@ -963,6 +1016,7 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
963
1016
|
type: 'category',
|
|
964
1017
|
label: 'Extension APIs (label from _category_.yml)',
|
|
965
1018
|
collapsed: true,
|
|
1019
|
+
collapsible: true,
|
|
966
1020
|
items: [
|
|
967
1021
|
{
|
|
968
1022
|
type: 'doc',
|
|
@@ -984,7 +1038,7 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
984
1038
|
});
|
|
985
1039
|
});
|
|
986
1040
|
|
|
987
|
-
test('docs in fully generated sidebar have correct
|
|
1041
|
+
test('docs in fully generated sidebar have correct metadata', async () => {
|
|
988
1042
|
const {content, siteDir} = await loadSite();
|
|
989
1043
|
const version = content.loadedVersions[0];
|
|
990
1044
|
|
|
@@ -993,7 +1047,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
993
1047
|
id: 'getting-started',
|
|
994
1048
|
unversionedId: 'getting-started',
|
|
995
1049
|
sourceDirName: '.',
|
|
996
|
-
isDocsHomePage: false,
|
|
997
1050
|
permalink: '/docs/getting-started',
|
|
998
1051
|
slug: '/getting-started',
|
|
999
1052
|
source: path.posix.join(
|
|
@@ -1019,7 +1072,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1019
1072
|
id: 'installation',
|
|
1020
1073
|
unversionedId: 'installation',
|
|
1021
1074
|
sourceDirName: '.',
|
|
1022
|
-
isDocsHomePage: false,
|
|
1023
1075
|
permalink: '/docs/installation',
|
|
1024
1076
|
slug: '/installation',
|
|
1025
1077
|
source: path.posix.join(
|
|
@@ -1048,7 +1100,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1048
1100
|
id: 'Guides/guide1',
|
|
1049
1101
|
unversionedId: 'Guides/guide1',
|
|
1050
1102
|
sourceDirName: 'Guides',
|
|
1051
|
-
isDocsHomePage: false,
|
|
1052
1103
|
permalink: '/docs/Guides/guide1',
|
|
1053
1104
|
slug: '/Guides/guide1',
|
|
1054
1105
|
source: path.posix.join(
|
|
@@ -1081,7 +1132,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1081
1132
|
id: 'Guides/guide2',
|
|
1082
1133
|
unversionedId: 'Guides/guide2',
|
|
1083
1134
|
sourceDirName: 'Guides',
|
|
1084
|
-
isDocsHomePage: false,
|
|
1085
1135
|
permalink: '/docs/Guides/guide2',
|
|
1086
1136
|
slug: '/Guides/guide2',
|
|
1087
1137
|
source: path.posix.join(
|
|
@@ -1113,7 +1163,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1113
1163
|
id: 'Guides/guide2.5',
|
|
1114
1164
|
unversionedId: 'Guides/guide2.5',
|
|
1115
1165
|
sourceDirName: 'Guides',
|
|
1116
|
-
isDocsHomePage: false,
|
|
1117
1166
|
permalink: '/docs/Guides/guide2.5',
|
|
1118
1167
|
slug: '/Guides/guide2.5',
|
|
1119
1168
|
source: path.posix.join(
|
|
@@ -1146,7 +1195,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1146
1195
|
id: 'Guides/guide3',
|
|
1147
1196
|
unversionedId: 'Guides/guide3',
|
|
1148
1197
|
sourceDirName: 'Guides',
|
|
1149
|
-
isDocsHomePage: false,
|
|
1150
1198
|
permalink: '/docs/Guides/guide3',
|
|
1151
1199
|
slug: '/Guides/guide3',
|
|
1152
1200
|
source: path.posix.join(
|
|
@@ -1179,7 +1227,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1179
1227
|
id: 'Guides/guide4',
|
|
1180
1228
|
unversionedId: 'Guides/guide4',
|
|
1181
1229
|
sourceDirName: 'Guides',
|
|
1182
|
-
isDocsHomePage: false,
|
|
1183
1230
|
permalink: '/docs/Guides/guide4',
|
|
1184
1231
|
slug: '/Guides/guide4',
|
|
1185
1232
|
source: path.posix.join(
|
|
@@ -1211,7 +1258,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1211
1258
|
id: 'Guides/guide5',
|
|
1212
1259
|
unversionedId: 'Guides/guide5',
|
|
1213
1260
|
sourceDirName: 'Guides',
|
|
1214
|
-
isDocsHomePage: false,
|
|
1215
1261
|
permalink: '/docs/Guides/guide5',
|
|
1216
1262
|
slug: '/Guides/guide5',
|
|
1217
1263
|
source: path.posix.join(
|
|
@@ -1243,7 +1289,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1243
1289
|
id: 'API/api-overview',
|
|
1244
1290
|
unversionedId: 'API/api-overview',
|
|
1245
1291
|
sourceDirName: '3-API',
|
|
1246
|
-
isDocsHomePage: false,
|
|
1247
1292
|
permalink: '/docs/API/api-overview',
|
|
1248
1293
|
slug: '/API/api-overview',
|
|
1249
1294
|
source: path.posix.join(
|
|
@@ -1273,7 +1318,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1273
1318
|
id: 'API/Core APIs/Client API',
|
|
1274
1319
|
unversionedId: 'API/Core APIs/Client API',
|
|
1275
1320
|
sourceDirName: '3-API/01_Core APIs',
|
|
1276
|
-
isDocsHomePage: false,
|
|
1277
1321
|
permalink: '/docs/API/Core APIs/Client API',
|
|
1278
1322
|
slug: '/API/Core APIs/Client API',
|
|
1279
1323
|
source: path.posix.join(
|
|
@@ -1304,7 +1348,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1304
1348
|
id: 'API/Core APIs/Server API',
|
|
1305
1349
|
unversionedId: 'API/Core APIs/Server API',
|
|
1306
1350
|
sourceDirName: '3-API/01_Core APIs',
|
|
1307
|
-
isDocsHomePage: false,
|
|
1308
1351
|
permalink: '/docs/API/Core APIs/Server API',
|
|
1309
1352
|
slug: '/API/Core APIs/Server API',
|
|
1310
1353
|
source: path.posix.join(
|
|
@@ -1335,7 +1378,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1335
1378
|
id: 'API/Extension APIs/Plugin API',
|
|
1336
1379
|
unversionedId: 'API/Extension APIs/Plugin API',
|
|
1337
1380
|
sourceDirName: '3-API/02_Extension APIs',
|
|
1338
|
-
isDocsHomePage: false,
|
|
1339
1381
|
permalink: '/docs/API/Extension APIs/Plugin API',
|
|
1340
1382
|
slug: '/API/Extension APIs/Plugin API',
|
|
1341
1383
|
source: path.posix.join(
|
|
@@ -1366,7 +1408,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1366
1408
|
id: 'API/Extension APIs/Theme API',
|
|
1367
1409
|
unversionedId: 'API/Extension APIs/Theme API',
|
|
1368
1410
|
sourceDirName: '3-API/02_Extension APIs',
|
|
1369
|
-
isDocsHomePage: false,
|
|
1370
1411
|
permalink: '/docs/API/Extension APIs/Theme API',
|
|
1371
1412
|
slug: '/API/Extension APIs/Theme API',
|
|
1372
1413
|
source: path.posix.join(
|
|
@@ -1397,7 +1438,6 @@ describe('site with full autogenerated sidebar', () => {
|
|
|
1397
1438
|
id: 'API/api-end',
|
|
1398
1439
|
unversionedId: 'API/api-end',
|
|
1399
1440
|
sourceDirName: '3-API',
|
|
1400
|
-
isDocsHomePage: false,
|
|
1401
1441
|
permalink: '/docs/API/api-end',
|
|
1402
1442
|
slug: '/API/api-end',
|
|
1403
1443
|
source: path.posix.join(
|
|
@@ -1461,6 +1501,7 @@ describe('site with partial autogenerated sidebars', () => {
|
|
|
1461
1501
|
type: 'category',
|
|
1462
1502
|
label: 'Some category',
|
|
1463
1503
|
collapsed: true,
|
|
1504
|
+
collapsible: true,
|
|
1464
1505
|
items: [
|
|
1465
1506
|
{
|
|
1466
1507
|
type: 'doc',
|
|
@@ -1480,18 +1521,17 @@ describe('site with partial autogenerated sidebars', () => {
|
|
|
1480
1521
|
});
|
|
1481
1522
|
});
|
|
1482
1523
|
|
|
1483
|
-
test('docs in partially generated sidebar have correct
|
|
1524
|
+
test('docs in partially generated sidebar have correct metadata', async () => {
|
|
1484
1525
|
const {content, siteDir} = await loadSite();
|
|
1485
1526
|
const version = content.loadedVersions[0];
|
|
1486
1527
|
|
|
1487
|
-
// Only looking at the docs of the autogen sidebar, others
|
|
1528
|
+
// Only looking at the docs of the autogen sidebar, others metadata should not be affected
|
|
1488
1529
|
|
|
1489
1530
|
expect(getDocById(version, 'API/api-end')).toEqual({
|
|
1490
1531
|
...defaultDocMetadata,
|
|
1491
1532
|
id: 'API/api-end',
|
|
1492
1533
|
unversionedId: 'API/api-end',
|
|
1493
1534
|
sourceDirName: '3-API',
|
|
1494
|
-
isDocsHomePage: false,
|
|
1495
1535
|
permalink: '/docs/API/api-end',
|
|
1496
1536
|
slug: '/API/api-end',
|
|
1497
1537
|
source: path.posix.join(
|
|
@@ -1518,7 +1558,6 @@ describe('site with partial autogenerated sidebars', () => {
|
|
|
1518
1558
|
id: 'API/api-overview',
|
|
1519
1559
|
unversionedId: 'API/api-overview',
|
|
1520
1560
|
sourceDirName: '3-API',
|
|
1521
|
-
isDocsHomePage: false,
|
|
1522
1561
|
permalink: '/docs/API/api-overview',
|
|
1523
1562
|
slug: '/API/api-overview',
|
|
1524
1563
|
source: path.posix.join(
|
|
@@ -1548,7 +1587,6 @@ describe('site with partial autogenerated sidebars', () => {
|
|
|
1548
1587
|
id: 'API/Extension APIs/Plugin API',
|
|
1549
1588
|
unversionedId: 'API/Extension APIs/Plugin API',
|
|
1550
1589
|
sourceDirName: '3-API/02_Extension APIs',
|
|
1551
|
-
isDocsHomePage: false,
|
|
1552
1590
|
permalink: '/docs/API/Extension APIs/Plugin API',
|
|
1553
1591
|
slug: '/API/Extension APIs/Plugin API',
|
|
1554
1592
|
source: path.posix.join(
|
|
@@ -1579,7 +1617,6 @@ describe('site with partial autogenerated sidebars', () => {
|
|
|
1579
1617
|
id: 'API/Extension APIs/Theme API',
|
|
1580
1618
|
unversionedId: 'API/Extension APIs/Theme API',
|
|
1581
1619
|
sourceDirName: '3-API/02_Extension APIs',
|
|
1582
|
-
isDocsHomePage: false,
|
|
1583
1620
|
permalink: '/docs/API/Extension APIs/Theme API',
|
|
1584
1621
|
slug: '/API/Extension APIs/Theme API',
|
|
1585
1622
|
source: path.posix.join(
|
|
@@ -1650,6 +1687,7 @@ describe('site with partial autogenerated sidebars 2 (fix #4638)', () => {
|
|
|
1650
1687
|
type: 'category',
|
|
1651
1688
|
label: 'Core APIs',
|
|
1652
1689
|
collapsed: true,
|
|
1690
|
+
collapsible: true,
|
|
1653
1691
|
items: [
|
|
1654
1692
|
{
|
|
1655
1693
|
type: 'doc',
|
|
@@ -1666,6 +1704,7 @@ describe('site with partial autogenerated sidebars 2 (fix #4638)', () => {
|
|
|
1666
1704
|
type: 'category',
|
|
1667
1705
|
label: 'Extension APIs (label from _category_.yml)', // Fix #4638
|
|
1668
1706
|
collapsed: true,
|
|
1707
|
+
collapsible: true,
|
|
1669
1708
|
items: [
|
|
1670
1709
|
{
|
|
1671
1710
|
type: 'doc',
|
|
@@ -1735,12 +1774,11 @@ describe('site with custom sidebar items generator', () => {
|
|
|
1735
1774
|
});
|
|
1736
1775
|
|
|
1737
1776
|
test('sidebar is autogenerated according to a custom sidebarItemsGenerator', async () => {
|
|
1738
|
-
const customSidebarItemsGenerator: SidebarItemsGeneratorOption =
|
|
1739
|
-
|
|
1777
|
+
const customSidebarItemsGenerator: SidebarItemsGeneratorOption =
|
|
1778
|
+
async () => [
|
|
1740
1779
|
{type: 'doc', id: 'API/api-overview'},
|
|
1741
1780
|
{type: 'doc', id: 'API/api-end'},
|
|
1742
1781
|
];
|
|
1743
|
-
};
|
|
1744
1782
|
|
|
1745
1783
|
const {content} = await loadSite(customSidebarItemsGenerator);
|
|
1746
1784
|
const version = content.loadedVersions[0];
|
|
@@ -1782,6 +1820,7 @@ describe('site with custom sidebar items generator', () => {
|
|
|
1782
1820
|
type: 'category',
|
|
1783
1821
|
label: 'API (label from _category_.json)',
|
|
1784
1822
|
collapsed: true,
|
|
1823
|
+
collapsible: true,
|
|
1785
1824
|
items: [
|
|
1786
1825
|
{
|
|
1787
1826
|
type: 'doc',
|
|
@@ -1791,6 +1830,7 @@ describe('site with custom sidebar items generator', () => {
|
|
|
1791
1830
|
type: 'category',
|
|
1792
1831
|
label: 'Extension APIs (label from _category_.yml)',
|
|
1793
1832
|
collapsed: true,
|
|
1833
|
+
collapsible: true,
|
|
1794
1834
|
items: [
|
|
1795
1835
|
{
|
|
1796
1836
|
type: 'doc',
|
|
@@ -1806,6 +1846,7 @@ describe('site with custom sidebar items generator', () => {
|
|
|
1806
1846
|
type: 'category',
|
|
1807
1847
|
label: 'Core APIs',
|
|
1808
1848
|
collapsed: true,
|
|
1849
|
+
collapsible: true,
|
|
1809
1850
|
items: [
|
|
1810
1851
|
{
|
|
1811
1852
|
type: 'doc',
|
|
@@ -1827,6 +1868,7 @@ describe('site with custom sidebar items generator', () => {
|
|
|
1827
1868
|
type: 'category',
|
|
1828
1869
|
label: 'Guides',
|
|
1829
1870
|
collapsed: true,
|
|
1871
|
+
collapsible: true,
|
|
1830
1872
|
items: [
|
|
1831
1873
|
{
|
|
1832
1874
|
type: 'doc',
|
|
@@ -40,7 +40,7 @@ describe('lastUpdate', () => {
|
|
|
40
40
|
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
|
|
41
41
|
expect(consoleMock).toHaveBeenCalledTimes(1);
|
|
42
42
|
expect(consoleMock.mock.calls[0][0].message).toContain(
|
|
43
|
-
|
|
43
|
+
' with exit code 128',
|
|
44
44
|
);
|
|
45
45
|
expect(await getFileLastUpdate(null)).toBeNull();
|
|
46
46
|
expect(await getFileLastUpdate(undefined)).toBeNull();
|
|
@@ -5,18 +5,30 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {OptionsSchema, DEFAULT_OPTIONS} from '../options';
|
|
8
|
+
import {OptionsSchema, DEFAULT_OPTIONS, validateOptions} from '../options';
|
|
9
9
|
import {normalizePluginOptions} from '@docusaurus/utils-validation';
|
|
10
|
-
import {DefaultSidebarItemsGenerator} from '../
|
|
10
|
+
import {DefaultSidebarItemsGenerator} from '../sidebars/generator';
|
|
11
11
|
import {
|
|
12
12
|
DefaultNumberPrefixParser,
|
|
13
13
|
DisabledNumberPrefixParser,
|
|
14
14
|
} from '../numberPrefix';
|
|
15
|
+
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
16
|
+
import {PluginOptions} from '../types';
|
|
15
17
|
|
|
16
18
|
// the type of remark/rehype plugins is function
|
|
17
19
|
const markdownPluginsFunctionStub = () => {};
|
|
18
20
|
const markdownPluginsObjectStub = {};
|
|
19
21
|
|
|
22
|
+
function testValidateOptions(options: Partial<PluginOptions>) {
|
|
23
|
+
return validateOptions({
|
|
24
|
+
options: {
|
|
25
|
+
...DEFAULT_OPTIONS,
|
|
26
|
+
...options,
|
|
27
|
+
},
|
|
28
|
+
validate: normalizePluginOptions,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
describe('normalizeDocsPluginOptions', () => {
|
|
21
33
|
test('should return default options for undefined user options', async () => {
|
|
22
34
|
const {value, error} = await OptionsSchema.validate({});
|
|
@@ -28,13 +40,18 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
28
40
|
const userOptions = {
|
|
29
41
|
path: 'my-docs', // Path to data on filesystem, relative to site dir.
|
|
30
42
|
routeBasePath: 'my-docs', // URL Route.
|
|
31
|
-
|
|
43
|
+
tagsBasePath: 'tags', // URL Tags Route.
|
|
32
44
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
|
45
|
+
exclude: GlobExcludeDefault,
|
|
33
46
|
sidebarPath: 'my-sidebar', // Path to sidebar configuration for showing a list of markdown pages.
|
|
34
47
|
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
|
35
48
|
numberPrefixParser: DefaultNumberPrefixParser,
|
|
36
49
|
docLayoutComponent: '@theme/DocPage',
|
|
37
50
|
docItemComponent: '@theme/DocItem',
|
|
51
|
+
docTagDocListComponent: '@theme/DocTagDocListPage',
|
|
52
|
+
docTagsListComponent: '@theme/DocTagsListPage',
|
|
53
|
+
docCategoryGeneratedIndexComponent:
|
|
54
|
+
'@theme/DocCategoryGeneratedIndexPage',
|
|
38
55
|
remarkPlugins: [markdownPluginsObjectStub],
|
|
39
56
|
rehypePlugins: [markdownPluginsFunctionStub],
|
|
40
57
|
beforeDefaultRehypePlugins: [],
|
|
@@ -56,6 +73,8 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
56
73
|
label: 'world',
|
|
57
74
|
},
|
|
58
75
|
},
|
|
76
|
+
sidebarCollapsible: false,
|
|
77
|
+
sidebarCollapsed: false,
|
|
59
78
|
};
|
|
60
79
|
const {value, error} = await OptionsSchema.validate(userOptions);
|
|
61
80
|
expect(value).toEqual(userOptions);
|
|
@@ -228,4 +247,30 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
228
247
|
`"\\"versions.current.hey\\" is not allowed"`,
|
|
229
248
|
);
|
|
230
249
|
});
|
|
250
|
+
|
|
251
|
+
test('should handle sidebarCollapsed option inconsistencies', () => {
|
|
252
|
+
expect(
|
|
253
|
+
testValidateOptions({
|
|
254
|
+
...DEFAULT_OPTIONS,
|
|
255
|
+
sidebarCollapsible: true,
|
|
256
|
+
sidebarCollapsed: undefined,
|
|
257
|
+
}).sidebarCollapsed,
|
|
258
|
+
).toEqual(true);
|
|
259
|
+
|
|
260
|
+
expect(
|
|
261
|
+
testValidateOptions({
|
|
262
|
+
...DEFAULT_OPTIONS,
|
|
263
|
+
sidebarCollapsible: false,
|
|
264
|
+
sidebarCollapsed: undefined,
|
|
265
|
+
}).sidebarCollapsed,
|
|
266
|
+
).toEqual(false);
|
|
267
|
+
|
|
268
|
+
expect(
|
|
269
|
+
testValidateOptions({
|
|
270
|
+
...DEFAULT_OPTIONS,
|
|
271
|
+
sidebarCollapsible: false,
|
|
272
|
+
sidebarCollapsed: true,
|
|
273
|
+
}).sidebarCollapsed,
|
|
274
|
+
).toEqual(false);
|
|
275
|
+
});
|
|
231
276
|
});
|