@docusaurus/plugin-content-docs 2.0.0-beta.0e652730d → 2.0.0-beta.10
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 +1 -4
- package/lib/client/docsClientUtils.js +21 -31
- package/lib/docFrontMatter.d.ts +1 -1
- package/lib/docFrontMatter.js +10 -6
- package/lib/docs.d.ts +25 -3
- package/lib/docs.js +125 -38
- package/lib/globalData.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +104 -138
- package/lib/lastUpdate.js +9 -10
- 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 +49 -17
- package/lib/props.d.ts +7 -2
- package/lib/props.js +61 -9
- 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 +24 -21
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +71 -29
- package/lib/types.d.ts +52 -62
- package/lib/versions.d.ts +3 -3
- package/lib/versions.js +76 -24
- package/package.json +22 -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 +753 -112
- package/src/__tests__/__snapshots__/translations.test.ts.snap +45 -18
- package/src/__tests__/cli.test.ts +15 -11
- package/src/__tests__/docFrontMatter.test.ts +195 -40
- package/src/__tests__/docs.test.ts +311 -150
- package/src/__tests__/index.test.ts +112 -69
- package/src/__tests__/lastUpdate.test.ts +3 -2
- package/src/__tests__/options.test.ts +48 -4
- package/src/__tests__/props.test.ts +62 -0
- package/src/__tests__/slug.test.ts +127 -20
- package/src/__tests__/translations.test.ts +7 -2
- package/src/__tests__/versions.test.ts +93 -67
- package/src/categoryGeneratedIndex.ts +57 -0
- package/src/cli.ts +8 -41
- package/src/client/__tests__/docsClientUtils.test.ts +4 -5
- package/src/client/docsClientUtils.ts +19 -41
- package/{types.d.ts → src/deps.d.ts} +0 -0
- package/src/docFrontMatter.ts +13 -7
- package/src/docs.ts +158 -29
- package/src/globalData.ts +6 -1
- package/src/index.ts +134 -179
- package/src/lastUpdate.ts +10 -9
- package/src/markdown/index.ts +8 -12
- package/src/numberPrefix.ts +5 -3
- package/src/options.ts +59 -28
- package/src/plugin-content-docs.d.ts +179 -35
- package/src/props.ts +91 -16
- 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/theme/hooks/useDocs.ts +5 -1
- package/src/translations.ts +103 -47
- package/src/types.ts +67 -105
- package/src/versions.ts +117 -21
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -43
- package/lib/sidebars.js +0 -319
- package/src/__tests__/sidebars.test.ts +0 -639
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -506
|
@@ -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: [],
|
|
@@ -42,7 +59,6 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
42
59
|
showLastUpdateTime: true,
|
|
43
60
|
showLastUpdateAuthor: true,
|
|
44
61
|
admonitions: {},
|
|
45
|
-
excludeNextVersionDocs: true,
|
|
46
62
|
includeCurrentVersion: false,
|
|
47
63
|
disableVersioning: true,
|
|
48
64
|
editCurrentVersion: true,
|
|
@@ -57,6 +73,8 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
57
73
|
label: 'world',
|
|
58
74
|
},
|
|
59
75
|
},
|
|
76
|
+
sidebarCollapsible: false,
|
|
77
|
+
sidebarCollapsed: false,
|
|
60
78
|
};
|
|
61
79
|
const {value, error} = await OptionsSchema.validate(userOptions);
|
|
62
80
|
expect(value).toEqual(userOptions);
|
|
@@ -229,4 +247,30 @@ describe('normalizeDocsPluginOptions', () => {
|
|
|
229
247
|
`"\\"versions.current.hey\\" is not allowed"`,
|
|
230
248
|
);
|
|
231
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
|
+
});
|
|
232
276
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {toTagDocListProp} from '../props';
|
|
9
|
+
|
|
10
|
+
describe('toTagDocListProp', () => {
|
|
11
|
+
type Params = Parameters<typeof toTagDocListProp>[0];
|
|
12
|
+
type Tag = Params['tag'];
|
|
13
|
+
type Doc = Params['docs'][number];
|
|
14
|
+
|
|
15
|
+
const allTagsPath = '/all/tags';
|
|
16
|
+
|
|
17
|
+
test('should work', () => {
|
|
18
|
+
const tag: Tag = {
|
|
19
|
+
name: 'tag1',
|
|
20
|
+
permalink: '/tag1',
|
|
21
|
+
docIds: ['id1', 'id3'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const doc1: Doc = {
|
|
25
|
+
id: 'id1',
|
|
26
|
+
title: 'ZZZ 1',
|
|
27
|
+
description: 'Description 1',
|
|
28
|
+
permalink: '/doc1',
|
|
29
|
+
};
|
|
30
|
+
const doc2: Doc = {
|
|
31
|
+
id: 'id2',
|
|
32
|
+
title: 'XXX 2',
|
|
33
|
+
description: 'Description 2',
|
|
34
|
+
permalink: '/doc2',
|
|
35
|
+
};
|
|
36
|
+
const doc3: Doc = {
|
|
37
|
+
id: 'id3',
|
|
38
|
+
title: 'AAA 3',
|
|
39
|
+
description: 'Description 3',
|
|
40
|
+
permalink: '/doc3',
|
|
41
|
+
};
|
|
42
|
+
const doc4: Doc = {
|
|
43
|
+
id: 'id4',
|
|
44
|
+
title: 'UUU 4',
|
|
45
|
+
description: 'Description 4',
|
|
46
|
+
permalink: '/doc4',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const result = toTagDocListProp({
|
|
50
|
+
allTagsPath,
|
|
51
|
+
tag,
|
|
52
|
+
docs: [doc1, doc2, doc3, doc4],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(result).toEqual({
|
|
56
|
+
allTagsPath,
|
|
57
|
+
name: tag.name,
|
|
58
|
+
permalink: tag.permalink,
|
|
59
|
+
docs: [doc3, doc1], // docs sorted by title, ignore "id5" absence
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -9,24 +9,92 @@ import getSlug from '../slug';
|
|
|
9
9
|
|
|
10
10
|
describe('getSlug', () => {
|
|
11
11
|
test('should default to dirname/id', () => {
|
|
12
|
-
expect(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
expect(
|
|
13
|
+
getSlug({
|
|
14
|
+
baseID: 'doc',
|
|
15
|
+
source: '@site/docs/dir/doc.md',
|
|
16
|
+
sourceDirName: '/dir',
|
|
17
|
+
}),
|
|
18
|
+
).toEqual('/dir/doc');
|
|
19
|
+
expect(
|
|
20
|
+
getSlug({
|
|
21
|
+
baseID: 'doc',
|
|
22
|
+
source: '@site/docs/dir/subdir/doc.md',
|
|
23
|
+
sourceDirName: '/dir/subdir',
|
|
24
|
+
}),
|
|
25
|
+
).toEqual('/dir/subdir/doc');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('should handle conventional doc indexes', () => {
|
|
29
|
+
expect(
|
|
30
|
+
getSlug({
|
|
31
|
+
baseID: 'doc',
|
|
32
|
+
source: '@site/docs/dir/subdir/index.md',
|
|
33
|
+
sourceDirName: '/dir/subdir',
|
|
34
|
+
}),
|
|
35
|
+
).toEqual('/dir/subdir/');
|
|
36
|
+
expect(
|
|
37
|
+
getSlug({
|
|
38
|
+
baseID: 'doc',
|
|
39
|
+
source: '@site/docs/dir/subdir/inDEx.mdx',
|
|
40
|
+
sourceDirName: '/dir/subdir',
|
|
41
|
+
}),
|
|
42
|
+
).toEqual('/dir/subdir/');
|
|
43
|
+
expect(
|
|
44
|
+
getSlug({
|
|
45
|
+
baseID: 'doc',
|
|
46
|
+
source: '@site/docs/dir/subdir/readme.md',
|
|
47
|
+
sourceDirName: '/dir/subdir',
|
|
48
|
+
}),
|
|
49
|
+
).toEqual('/dir/subdir/');
|
|
50
|
+
expect(
|
|
51
|
+
getSlug({
|
|
52
|
+
baseID: 'doc',
|
|
53
|
+
source: '@site/docs/dir/subdir/reADMe.mdx',
|
|
54
|
+
sourceDirName: '/dir/subdir',
|
|
55
|
+
}),
|
|
56
|
+
).toEqual('/dir/subdir/');
|
|
57
|
+
expect(
|
|
58
|
+
getSlug({
|
|
59
|
+
baseID: 'doc',
|
|
60
|
+
source: '@site/docs/dir/subdir/subdir.md',
|
|
61
|
+
sourceDirName: '/dir/subdir',
|
|
62
|
+
}),
|
|
63
|
+
).toEqual('/dir/subdir/');
|
|
64
|
+
expect(
|
|
65
|
+
getSlug({
|
|
66
|
+
baseID: 'doc',
|
|
67
|
+
source: '@site/docs/dir/subdir/suBDir.mdx',
|
|
68
|
+
sourceDirName: '/dir/subdir',
|
|
69
|
+
}),
|
|
70
|
+
).toEqual('/dir/subdir/');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('should ignore conventional doc index when explicit slug frontmatter is provided', () => {
|
|
74
|
+
expect(
|
|
75
|
+
getSlug({
|
|
76
|
+
baseID: 'doc',
|
|
77
|
+
source: '@site/docs/dir/subdir/index.md',
|
|
78
|
+
sourceDirName: '/dir/subdir',
|
|
79
|
+
frontmatterSlug: '/my/frontMatterSlug',
|
|
80
|
+
}),
|
|
81
|
+
).toEqual('/my/frontMatterSlug');
|
|
16
82
|
});
|
|
17
83
|
|
|
18
84
|
test('can strip dir number prefixes', () => {
|
|
19
85
|
expect(
|
|
20
86
|
getSlug({
|
|
21
87
|
baseID: 'doc',
|
|
22
|
-
|
|
88
|
+
source: '@site/docs/001-dir1/002-dir2/doc.md',
|
|
89
|
+
sourceDirName: '/001-dir1/002-dir2',
|
|
23
90
|
stripDirNumberPrefixes: true,
|
|
24
91
|
}),
|
|
25
92
|
).toEqual('/dir1/dir2/doc');
|
|
26
93
|
expect(
|
|
27
94
|
getSlug({
|
|
28
95
|
baseID: 'doc',
|
|
29
|
-
|
|
96
|
+
source: '@site/docs/001-dir1/002-dir2/doc.md',
|
|
97
|
+
sourceDirName: '/001-dir1/002-dir2',
|
|
30
98
|
stripDirNumberPrefixes: false,
|
|
31
99
|
}),
|
|
32
100
|
).toEqual('/001-dir1/002-dir2/doc');
|
|
@@ -35,26 +103,45 @@ describe('getSlug', () => {
|
|
|
35
103
|
// See https://github.com/facebook/docusaurus/issues/3223
|
|
36
104
|
test('should handle special chars in doc path', () => {
|
|
37
105
|
expect(
|
|
38
|
-
getSlug({
|
|
106
|
+
getSlug({
|
|
107
|
+
baseID: 'my dôc',
|
|
108
|
+
source: '@site/docs/dir with spâce/hey $hello/doc.md',
|
|
109
|
+
sourceDirName: '/dir with spâce/hey $hello',
|
|
110
|
+
}),
|
|
39
111
|
).toEqual('/dir with spâce/hey $hello/my dôc');
|
|
40
112
|
});
|
|
41
113
|
|
|
42
114
|
test('should handle current dir', () => {
|
|
43
|
-
expect(
|
|
44
|
-
|
|
115
|
+
expect(
|
|
116
|
+
getSlug({baseID: 'doc', source: '@site/docs/doc.md', sourceDirName: '.'}),
|
|
117
|
+
).toEqual('/doc');
|
|
118
|
+
expect(
|
|
119
|
+
getSlug({baseID: 'doc', source: '@site/docs/doc.md', sourceDirName: '/'}),
|
|
120
|
+
).toEqual('/doc');
|
|
45
121
|
});
|
|
46
122
|
|
|
47
123
|
test('should resolve absolute slug frontmatter', () => {
|
|
48
124
|
expect(
|
|
49
|
-
getSlug({
|
|
125
|
+
getSlug({
|
|
126
|
+
baseID: 'any',
|
|
127
|
+
source: '@site/docs/doc.md',
|
|
128
|
+
sourceDirName: '.',
|
|
129
|
+
frontmatterSlug: '/abc/def',
|
|
130
|
+
}),
|
|
50
131
|
).toEqual('/abc/def');
|
|
51
132
|
expect(
|
|
52
|
-
getSlug({
|
|
133
|
+
getSlug({
|
|
134
|
+
baseID: 'any',
|
|
135
|
+
source: '@site/docs/any/doc.md',
|
|
136
|
+
sourceDirName: './any',
|
|
137
|
+
frontmatterSlug: '/abc/def',
|
|
138
|
+
}),
|
|
53
139
|
).toEqual('/abc/def');
|
|
54
140
|
expect(
|
|
55
141
|
getSlug({
|
|
56
142
|
baseID: 'any',
|
|
57
|
-
|
|
143
|
+
source: '@site/docs/any/any/doc.md',
|
|
144
|
+
sourceDirName: './any/any',
|
|
58
145
|
frontmatterSlug: '/abc/def',
|
|
59
146
|
}),
|
|
60
147
|
).toEqual('/abc/def');
|
|
@@ -62,46 +149,66 @@ describe('getSlug', () => {
|
|
|
62
149
|
|
|
63
150
|
test('should resolve relative slug frontmatter', () => {
|
|
64
151
|
expect(
|
|
65
|
-
getSlug({
|
|
152
|
+
getSlug({
|
|
153
|
+
baseID: 'any',
|
|
154
|
+
source: '@site/docs/doc.md',
|
|
155
|
+
sourceDirName: '.',
|
|
156
|
+
frontmatterSlug: 'abc/def',
|
|
157
|
+
}),
|
|
66
158
|
).toEqual('/abc/def');
|
|
67
159
|
expect(
|
|
68
|
-
getSlug({
|
|
160
|
+
getSlug({
|
|
161
|
+
baseID: 'any',
|
|
162
|
+
source: '@site/docs/dir/doc.md',
|
|
163
|
+
sourceDirName: '/dir',
|
|
164
|
+
frontmatterSlug: 'abc/def',
|
|
165
|
+
}),
|
|
69
166
|
).toEqual('/dir/abc/def');
|
|
70
167
|
expect(
|
|
71
168
|
getSlug({
|
|
72
169
|
baseID: 'any',
|
|
73
|
-
|
|
170
|
+
source: '@site/docs/unslashedDir/doc.md',
|
|
171
|
+
sourceDirName: 'unslashedDir',
|
|
74
172
|
frontmatterSlug: 'abc/def',
|
|
75
173
|
}),
|
|
76
174
|
).toEqual('/unslashedDir/abc/def');
|
|
77
175
|
expect(
|
|
78
176
|
getSlug({
|
|
79
177
|
baseID: 'any',
|
|
80
|
-
|
|
178
|
+
source: '@site/docs/dir/subdir/doc.md',
|
|
179
|
+
sourceDirName: 'dir/subdir',
|
|
81
180
|
frontmatterSlug: 'abc/def',
|
|
82
181
|
}),
|
|
83
182
|
).toEqual('/dir/subdir/abc/def');
|
|
84
183
|
expect(
|
|
85
|
-
getSlug({
|
|
184
|
+
getSlug({
|
|
185
|
+
baseID: 'any',
|
|
186
|
+
source: '@site/docs/dir/doc.md',
|
|
187
|
+
sourceDirName: '/dir',
|
|
188
|
+
frontmatterSlug: './abc/def',
|
|
189
|
+
}),
|
|
86
190
|
).toEqual('/dir/abc/def');
|
|
87
191
|
expect(
|
|
88
192
|
getSlug({
|
|
89
193
|
baseID: 'any',
|
|
90
|
-
|
|
194
|
+
source: '@site/docs/dir/doc.md',
|
|
195
|
+
sourceDirName: '/dir',
|
|
91
196
|
frontmatterSlug: './abc/../def',
|
|
92
197
|
}),
|
|
93
198
|
).toEqual('/dir/def');
|
|
94
199
|
expect(
|
|
95
200
|
getSlug({
|
|
96
201
|
baseID: 'any',
|
|
97
|
-
|
|
202
|
+
source: '@site/docs/dir/subdir/doc.md',
|
|
203
|
+
sourceDirName: '/dir/subdir',
|
|
98
204
|
frontmatterSlug: '../abc/def',
|
|
99
205
|
}),
|
|
100
206
|
).toEqual('/dir/abc/def');
|
|
101
207
|
expect(
|
|
102
208
|
getSlug({
|
|
103
209
|
baseID: 'any',
|
|
104
|
-
|
|
210
|
+
source: '@site/docs/dir/subdirdoc.md',
|
|
211
|
+
sourceDirName: '/dir/subdir',
|
|
105
212
|
frontmatterSlug: '../../../../../abc/../def',
|
|
106
213
|
}),
|
|
107
214
|
).toEqual('/def');
|
|
@@ -16,7 +16,6 @@ import {updateTranslationFileMessages} from '@docusaurus/utils';
|
|
|
16
16
|
function createSampleDoc(doc: Pick<DocMetadata, 'id'>): DocMetadata {
|
|
17
17
|
return {
|
|
18
18
|
editUrl: 'any',
|
|
19
|
-
isDocsHomePage: false,
|
|
20
19
|
lastUpdatedAt: 0,
|
|
21
20
|
lastUpdatedBy: 'any',
|
|
22
21
|
next: undefined,
|
|
@@ -40,7 +39,6 @@ function createSampleVersion(
|
|
|
40
39
|
versionLabel: `${version.versionName} label`,
|
|
41
40
|
versionPath: '/docs/',
|
|
42
41
|
mainDocId: '',
|
|
43
|
-
permalinkToSidebar: {},
|
|
44
42
|
routePriority: undefined,
|
|
45
43
|
sidebarFilePath: 'any',
|
|
46
44
|
isLast: true,
|
|
@@ -69,6 +67,13 @@ function createSampleVersion(
|
|
|
69
67
|
type: 'category',
|
|
70
68
|
label: 'Getting started',
|
|
71
69
|
collapsed: false,
|
|
70
|
+
link: {
|
|
71
|
+
type: 'generated-index',
|
|
72
|
+
slug: '/category/getting-started-index-slug',
|
|
73
|
+
permalink: '/docs/category/getting-started-index-slug',
|
|
74
|
+
title: 'Getting started index title',
|
|
75
|
+
description: 'Getting started index description',
|
|
76
|
+
},
|
|
72
77
|
items: [
|
|
73
78
|
{
|
|
74
79
|
type: 'doc',
|