@docusaurus/plugin-content-docs 2.0.0-beta.138b4c997 → 2.0.0-beta.14
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/categoryGeneratedIndex.d.ts +12 -0
- package/lib/categoryGeneratedIndex.js +37 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +14 -35
- 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 +8 -4
- package/lib/docs.d.ts +25 -3
- package/lib/docs.js +126 -41
- package/lib/globalData.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +101 -133
- package/lib/lastUpdate.js +12 -12
- 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 -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/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
- 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/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/tags.d.ts} +2 -8
- 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 -64
- package/lib/versions.d.ts +3 -3
- package/lib/versions.js +41 -22
- package/package.json +20 -20
- package/src/categoryGeneratedIndex.ts +57 -0
- package/src/cli.ts +10 -42
- package/src/client/docsClientUtils.ts +14 -26
- package/{types.d.ts → src/deps.d.ts} +0 -0
- package/src/docFrontMatter.ts +10 -5
- package/src/docs.ts +164 -36
- package/src/globalData.ts +6 -1
- package/src/index.ts +127 -177
- package/src/lastUpdate.ts +14 -16
- package/src/markdown/index.ts +8 -12
- package/src/numberPrefix.ts +5 -3
- package/src/options.ts +56 -15
- package/src/plugin-content-docs.d.ts +172 -43
- package/src/props.ts +90 -16
- package/src/routes.ts +169 -0
- package/src/sidebars/generator.ts +302 -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 +64 -108
- package/src/versions.ts +59 -25
- package/lib/.tsbuildinfo +0 -1
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -43
- package/lib/sidebars.js +0 -320
- package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
- package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
- package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
- package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
- package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
- package/src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
- package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
- package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
- package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -70
- package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -53
- package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
- package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
- package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
- package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
- package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
- package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
- package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1916
- package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -487
- package/src/__tests__/cli.test.ts +0 -333
- package/src/__tests__/docFrontMatter.test.ts +0 -244
- package/src/__tests__/docs.test.ts +0 -878
- package/src/__tests__/index.test.ts +0 -1871
- package/src/__tests__/lastUpdate.test.ts +0 -69
- package/src/__tests__/numberPrefix.test.ts +0 -199
- package/src/__tests__/options.test.ts +0 -231
- package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
- package/src/__tests__/sidebars.test.ts +0 -639
- package/src/__tests__/slug.test.ts +0 -109
- package/src/__tests__/translations.test.ts +0 -159
- package/src/__tests__/versions.test.ts +0 -741
- package/src/client/__tests__/docsClientUtils.test.ts +0 -371
- package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
- package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
- package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
- package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
- package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
- package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
- package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
- package/src/markdown/__tests__/linkify.test.ts +0 -190
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -522
- package/tsconfig.json +0 -9
package/src/index.ts
CHANGED
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
STATIC_DIR_NAME,
|
|
12
|
-
DEFAULT_PLUGIN_ID,
|
|
13
|
-
} from '@docusaurus/core/lib/constants';
|
|
14
10
|
import {
|
|
15
11
|
normalizeUrl,
|
|
16
12
|
docuHash,
|
|
@@ -18,10 +14,19 @@ import {
|
|
|
18
14
|
reportMessage,
|
|
19
15
|
posixPath,
|
|
20
16
|
addTrailingPathSeparator,
|
|
17
|
+
createAbsoluteFilePathMatcher,
|
|
18
|
+
createSlugger,
|
|
19
|
+
DEFAULT_PLUGIN_ID,
|
|
21
20
|
} from '@docusaurus/utils';
|
|
22
|
-
import {LoadContext, Plugin
|
|
23
|
-
import {loadSidebars
|
|
24
|
-
import {
|
|
21
|
+
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
22
|
+
import {loadSidebars} from './sidebars';
|
|
23
|
+
import {CategoryMetadataFilenamePattern} from './sidebars/generator';
|
|
24
|
+
import {
|
|
25
|
+
readVersionDocs,
|
|
26
|
+
processDocMetadata,
|
|
27
|
+
addDocNavigation,
|
|
28
|
+
getMainDocId,
|
|
29
|
+
} from './docs';
|
|
25
30
|
import {getDocsDirPaths, readVersionsMetadata} from './versions';
|
|
26
31
|
|
|
27
32
|
import {
|
|
@@ -29,27 +34,29 @@ import {
|
|
|
29
34
|
LoadedContent,
|
|
30
35
|
SourceToPermalink,
|
|
31
36
|
DocMetadataBase,
|
|
32
|
-
DocMetadata,
|
|
33
37
|
GlobalPluginData,
|
|
34
38
|
VersionMetadata,
|
|
35
|
-
DocNavLink,
|
|
36
39
|
LoadedVersion,
|
|
37
40
|
DocFile,
|
|
38
41
|
DocsMarkdownOption,
|
|
42
|
+
VersionTag,
|
|
39
43
|
} from './types';
|
|
40
|
-
import {
|
|
41
|
-
import {RuleSetRule} from 'webpack';
|
|
44
|
+
import type {RuleSetRule} from 'webpack';
|
|
42
45
|
import {cliDocsVersionCommand} from './cli';
|
|
43
46
|
import {VERSIONS_JSON_FILE} from './constants';
|
|
44
|
-
import {
|
|
47
|
+
import {keyBy, mapValues} from 'lodash';
|
|
45
48
|
import {toGlobalDataVersion} from './globalData';
|
|
46
|
-
import {
|
|
49
|
+
import {toTagDocListProp} from './props';
|
|
47
50
|
import {
|
|
48
51
|
translateLoadedContent,
|
|
49
52
|
getLoadedContentTranslationFiles,
|
|
50
53
|
} from './translations';
|
|
51
|
-
import
|
|
52
|
-
import
|
|
54
|
+
import logger from '@docusaurus/logger';
|
|
55
|
+
import {getVersionTags} from './tags';
|
|
56
|
+
import {createVersionRoutes} from './routes';
|
|
57
|
+
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
|
|
58
|
+
import {createSidebarsUtils} from './sidebars/utils';
|
|
59
|
+
import {getCategoryGeneratedIndexMetadataList} from './categoryGeneratedIndex';
|
|
53
60
|
|
|
54
61
|
export default function pluginContentDocs(
|
|
55
62
|
context: LoadContext,
|
|
@@ -100,6 +107,8 @@ export default function pluginContentDocs(
|
|
|
100
107
|
cliDocsVersionCommand(version, siteDir, pluginId, {
|
|
101
108
|
path: options.path,
|
|
102
109
|
sidebarPath: options.sidebarPath,
|
|
110
|
+
sidebarCollapsed: options.sidebarCollapsed,
|
|
111
|
+
sidebarCollapsible: options.sidebarCollapsible,
|
|
103
112
|
});
|
|
104
113
|
});
|
|
105
114
|
},
|
|
@@ -108,22 +117,12 @@ export default function pluginContentDocs(
|
|
|
108
117
|
return getLoadedContentTranslationFiles(content);
|
|
109
118
|
},
|
|
110
119
|
|
|
111
|
-
getClientModules() {
|
|
112
|
-
const modules = [];
|
|
113
|
-
if (options.admonitions) {
|
|
114
|
-
modules.push(require.resolve('remark-admonitions/styles/infima.css'));
|
|
115
|
-
}
|
|
116
|
-
return modules;
|
|
117
|
-
},
|
|
118
|
-
|
|
119
120
|
getPathsToWatch() {
|
|
120
121
|
function getVersionPathsToWatch(version: VersionMetadata): string[] {
|
|
121
122
|
const result = [
|
|
122
|
-
...
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
(docsDirPath) => `${docsDirPath}/${pattern}`,
|
|
126
|
-
),
|
|
123
|
+
...options.include.flatMap((pattern) =>
|
|
124
|
+
getDocsDirPaths(version).map(
|
|
125
|
+
(docsDirPath) => `${docsDirPath}/${pattern}`,
|
|
127
126
|
),
|
|
128
127
|
),
|
|
129
128
|
`${version.contentPath}/**/${CategoryMetadataFilenamePattern}`,
|
|
@@ -134,7 +133,7 @@ export default function pluginContentDocs(
|
|
|
134
133
|
return result;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
return
|
|
136
|
+
return versionsMetadata.flatMap(getVersionPathsToWatch);
|
|
138
137
|
},
|
|
139
138
|
|
|
140
139
|
async loadContent() {
|
|
@@ -166,98 +165,37 @@ export default function pluginContentDocs(
|
|
|
166
165
|
async function doLoadVersion(
|
|
167
166
|
versionMetadata: VersionMetadata,
|
|
168
167
|
): Promise<LoadedVersion> {
|
|
169
|
-
const
|
|
170
|
-
versionMetadata.sidebarFilePath,
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
const docsBase: DocMetadataBase[] = await loadVersionDocsBase(
|
|
168
|
+
const docs: DocMetadataBase[] = await loadVersionDocsBase(
|
|
174
169
|
versionMetadata,
|
|
175
170
|
);
|
|
176
|
-
const docsBaseById: Record<string, DocMetadataBase> = keyBy(
|
|
177
|
-
docsBase,
|
|
178
|
-
(doc) => doc.id,
|
|
179
|
-
);
|
|
180
171
|
|
|
181
|
-
const sidebars = await
|
|
172
|
+
const sidebars = await loadSidebars(versionMetadata.sidebarFilePath, {
|
|
182
173
|
sidebarItemsGenerator: options.sidebarItemsGenerator,
|
|
183
174
|
numberPrefixParser: options.numberPrefixParser,
|
|
184
|
-
|
|
185
|
-
docs: docsBase,
|
|
175
|
+
docs,
|
|
186
176
|
version: versionMetadata,
|
|
177
|
+
sidebarOptions: {
|
|
178
|
+
sidebarCollapsed: options.sidebarCollapsed,
|
|
179
|
+
sidebarCollapsible: options.sidebarCollapsible,
|
|
180
|
+
},
|
|
181
|
+
categoryLabelSlugger: createSlugger(),
|
|
187
182
|
});
|
|
188
183
|
|
|
189
184
|
const sidebarsUtils = createSidebarsUtils(sidebars);
|
|
190
185
|
|
|
191
|
-
const validDocIds = Object.keys(docsBaseById);
|
|
192
|
-
sidebarsUtils.checkSidebarsDocIds(
|
|
193
|
-
validDocIds,
|
|
194
|
-
versionMetadata.sidebarFilePath as string,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
// Add sidebar/next/previous to the docs
|
|
198
|
-
function addNavData(doc: DocMetadataBase): DocMetadata {
|
|
199
|
-
const {
|
|
200
|
-
sidebarName,
|
|
201
|
-
previousId,
|
|
202
|
-
nextId,
|
|
203
|
-
} = sidebarsUtils.getDocNavigation(doc.id);
|
|
204
|
-
const toDocNavLink = (navDocId: string): DocNavLink => {
|
|
205
|
-
const {title, permalink, frontMatter} = docsBaseById[navDocId];
|
|
206
|
-
return {
|
|
207
|
-
title:
|
|
208
|
-
frontMatter.pagination_label ??
|
|
209
|
-
frontMatter.sidebar_label ??
|
|
210
|
-
title,
|
|
211
|
-
permalink,
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
return {
|
|
215
|
-
...doc,
|
|
216
|
-
sidebar: sidebarName,
|
|
217
|
-
previous: previousId ? toDocNavLink(previousId) : undefined,
|
|
218
|
-
next: nextId ? toDocNavLink(nextId) : undefined,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const docs = docsBase.map(addNavData);
|
|
223
|
-
|
|
224
|
-
// sort to ensure consistent output for tests
|
|
225
|
-
docs.sort((a, b) => a.id.localeCompare(b.id));
|
|
226
|
-
|
|
227
|
-
// TODO really useful? replace with global state logic?
|
|
228
|
-
const permalinkToSidebar: PermalinkToSidebar = {};
|
|
229
|
-
Object.values(docs).forEach((doc) => {
|
|
230
|
-
if (doc.sidebar) {
|
|
231
|
-
permalinkToSidebar[doc.permalink] = doc.sidebar;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// The "main doc" is the "version entry point"
|
|
236
|
-
// We browse this doc by clicking on a version:
|
|
237
|
-
// - the "home" doc (at '/docs/')
|
|
238
|
-
// - the first doc of the first sidebar
|
|
239
|
-
// - a random doc (if no docs are in any sidebar... edge case)
|
|
240
|
-
function getMainDoc(): DocMetadata {
|
|
241
|
-
const versionHomeDoc = docs.find(
|
|
242
|
-
(doc) =>
|
|
243
|
-
doc.unversionedId === options.homePageId || doc.slug === '/',
|
|
244
|
-
);
|
|
245
|
-
const firstDocIdOfFirstSidebar = sidebarsUtils.getFirstDocIdOfFirstSidebar();
|
|
246
|
-
if (versionHomeDoc) {
|
|
247
|
-
return versionHomeDoc;
|
|
248
|
-
} else if (firstDocIdOfFirstSidebar) {
|
|
249
|
-
return docs.find((doc) => doc.id === firstDocIdOfFirstSidebar)!;
|
|
250
|
-
} else {
|
|
251
|
-
return docs[0];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
186
|
return {
|
|
256
187
|
...versionMetadata,
|
|
257
|
-
|
|
188
|
+
docs: addDocNavigation(
|
|
189
|
+
docs,
|
|
190
|
+
sidebarsUtils,
|
|
191
|
+
versionMetadata.sidebarFilePath as string,
|
|
192
|
+
),
|
|
258
193
|
sidebars,
|
|
259
|
-
|
|
260
|
-
|
|
194
|
+
mainDocId: getMainDocId({docs, sidebarsUtils}),
|
|
195
|
+
categoryGeneratedIndices: getCategoryGeneratedIndexMetadataList({
|
|
196
|
+
docs,
|
|
197
|
+
sidebarsUtils,
|
|
198
|
+
}),
|
|
261
199
|
};
|
|
262
200
|
}
|
|
263
201
|
|
|
@@ -265,11 +203,7 @@ export default function pluginContentDocs(
|
|
|
265
203
|
try {
|
|
266
204
|
return await doLoadVersion(versionMetadata);
|
|
267
205
|
} catch (e) {
|
|
268
|
-
|
|
269
|
-
chalk.red(
|
|
270
|
-
`Loading of version failed for version "${versionMetadata.versionName}"`,
|
|
271
|
-
),
|
|
272
|
-
);
|
|
206
|
+
logger.error`Loading of version failed for version name=${versionMetadata.versionName}`;
|
|
273
207
|
throw e;
|
|
274
208
|
}
|
|
275
209
|
}
|
|
@@ -285,76 +219,84 @@ export default function pluginContentDocs(
|
|
|
285
219
|
|
|
286
220
|
async contentLoaded({content, actions}) {
|
|
287
221
|
const {loadedVersions} = content;
|
|
288
|
-
const {
|
|
222
|
+
const {
|
|
223
|
+
docLayoutComponent,
|
|
224
|
+
docItemComponent,
|
|
225
|
+
docCategoryGeneratedIndexComponent,
|
|
226
|
+
} = options;
|
|
289
227
|
const {addRoute, createData, setGlobalData} = actions;
|
|
290
228
|
|
|
291
|
-
|
|
292
|
-
docs
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
229
|
+
async function createVersionTagsRoutes(version: LoadedVersion) {
|
|
230
|
+
const versionTags = getVersionTags(version.docs);
|
|
231
|
+
|
|
232
|
+
// TODO tags should be a sub route of the version route
|
|
233
|
+
async function createTagsListPage() {
|
|
234
|
+
const tagsProp: PropTagsListPage['tags'] = Object.values(
|
|
235
|
+
versionTags,
|
|
236
|
+
).map((tagValue) => ({
|
|
237
|
+
name: tagValue.name,
|
|
238
|
+
permalink: tagValue.permalink,
|
|
239
|
+
count: tagValue.docIds.length,
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
// Only create /tags page if there are tags.
|
|
243
|
+
if (Object.keys(tagsProp).length > 0) {
|
|
244
|
+
const tagsPropPath = await createData(
|
|
245
|
+
`${docuHash(`tags-list-${version.versionName}-prop`)}.json`,
|
|
246
|
+
JSON.stringify(tagsProp, null, 2),
|
|
301
247
|
);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
path: metadataItem.permalink,
|
|
305
|
-
component: docItemComponent,
|
|
248
|
+
addRoute({
|
|
249
|
+
path: version.tagsPath,
|
|
306
250
|
exact: true,
|
|
251
|
+
component: options.docTagsListComponent,
|
|
307
252
|
modules: {
|
|
308
|
-
|
|
253
|
+
tags: aliasedSource(tagsPropPath),
|
|
309
254
|
},
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return routes.sort((a, b) => a.path.localeCompare(b.path));
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
async function doCreateVersionRoutes(loadedVersion: LoadedVersion) {
|
|
318
|
-
const versionMetadataPropPath = await createData(
|
|
319
|
-
`${docuHash(
|
|
320
|
-
`version-${loadedVersion.versionName}-metadata-prop`,
|
|
321
|
-
)}.json`,
|
|
322
|
-
JSON.stringify(
|
|
323
|
-
toVersionMetadataProp(pluginId, loadedVersion),
|
|
324
|
-
null,
|
|
325
|
-
2,
|
|
326
|
-
),
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
addRoute({
|
|
330
|
-
path: loadedVersion.versionPath,
|
|
331
|
-
// allow matching /docs/* as well
|
|
332
|
-
exact: false,
|
|
333
|
-
// main docs component (DocPage)
|
|
334
|
-
component: docLayoutComponent,
|
|
335
|
-
// sub-routes for each doc
|
|
336
|
-
routes: await createDocRoutes(loadedVersion.docs),
|
|
337
|
-
modules: {
|
|
338
|
-
versionMetadata: aliasedSource(versionMetadataPropPath),
|
|
339
|
-
},
|
|
340
|
-
priority: loadedVersion.routePriority,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
343
258
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
259
|
+
// TODO tags should be a sub route of the version route
|
|
260
|
+
async function createTagDocListPage(tag: VersionTag) {
|
|
261
|
+
const tagProps = toTagDocListProp({
|
|
262
|
+
allTagsPath: version.tagsPath,
|
|
263
|
+
tag,
|
|
264
|
+
docs: version.docs,
|
|
265
|
+
});
|
|
266
|
+
const tagPropPath = await createData(
|
|
267
|
+
`${docuHash(`tag-${tag.permalink}`)}.json`,
|
|
268
|
+
JSON.stringify(tagProps, null, 2),
|
|
352
269
|
);
|
|
353
|
-
|
|
270
|
+
addRoute({
|
|
271
|
+
path: tag.permalink,
|
|
272
|
+
component: options.docTagDocListComponent,
|
|
273
|
+
exact: true,
|
|
274
|
+
modules: {
|
|
275
|
+
tag: aliasedSource(tagPropPath),
|
|
276
|
+
},
|
|
277
|
+
});
|
|
354
278
|
}
|
|
279
|
+
|
|
280
|
+
await createTagsListPage();
|
|
281
|
+
await Promise.all(Object.values(versionTags).map(createTagDocListPage));
|
|
355
282
|
}
|
|
356
283
|
|
|
357
|
-
await Promise.all(
|
|
284
|
+
await Promise.all(
|
|
285
|
+
loadedVersions.map((loadedVersion) =>
|
|
286
|
+
createVersionRoutes({
|
|
287
|
+
loadedVersion,
|
|
288
|
+
docItemComponent,
|
|
289
|
+
docLayoutComponent,
|
|
290
|
+
docCategoryGeneratedIndexComponent,
|
|
291
|
+
pluginId,
|
|
292
|
+
aliasedSource,
|
|
293
|
+
actions,
|
|
294
|
+
}),
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// TODO tags should be a sub route of the version route
|
|
299
|
+
await Promise.all(loadedVersions.map(createVersionTagsRoutes));
|
|
358
300
|
|
|
359
301
|
setGlobalData<GlobalPluginData>({
|
|
360
302
|
path: normalizeUrl([baseUrl, options.routeBasePath]),
|
|
@@ -372,7 +314,7 @@ export default function pluginContentDocs(
|
|
|
372
314
|
} = options;
|
|
373
315
|
|
|
374
316
|
function getSourceToPermalink(): SourceToPermalink {
|
|
375
|
-
const allDocs =
|
|
317
|
+
const allDocs = content.loadedVersions.flatMap((v) => v.docs);
|
|
376
318
|
return mapValues(
|
|
377
319
|
keyBy(allDocs, (d) => d.source),
|
|
378
320
|
(d) => d.permalink,
|
|
@@ -395,12 +337,13 @@ export default function pluginContentDocs(
|
|
|
395
337
|
};
|
|
396
338
|
|
|
397
339
|
function createMDXLoaderRule(): RuleSetRule {
|
|
340
|
+
const contentDirs = versionsMetadata.flatMap(getDocsDirPaths);
|
|
398
341
|
return {
|
|
399
342
|
test: /(\.mdx?)$/,
|
|
400
|
-
include:
|
|
343
|
+
include: contentDirs
|
|
401
344
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
402
345
|
.map(addTrailingPathSeparator),
|
|
403
|
-
use:
|
|
346
|
+
use: [
|
|
404
347
|
getJSLoader({isServer}),
|
|
405
348
|
{
|
|
406
349
|
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
@@ -409,7 +352,14 @@ export default function pluginContentDocs(
|
|
|
409
352
|
rehypePlugins,
|
|
410
353
|
beforeDefaultRehypePlugins,
|
|
411
354
|
beforeDefaultRemarkPlugins,
|
|
412
|
-
|
|
355
|
+
staticDirs: siteConfig.staticDirectories.map((dir) =>
|
|
356
|
+
path.resolve(siteDir, dir),
|
|
357
|
+
),
|
|
358
|
+
siteDir,
|
|
359
|
+
isMDXPartial: createAbsoluteFilePathMatcher(
|
|
360
|
+
options.exclude,
|
|
361
|
+
contentDirs,
|
|
362
|
+
),
|
|
413
363
|
metadataPath: (mdxPath: string) => {
|
|
414
364
|
// Note that metadataPath must be the same/in-sync as
|
|
415
365
|
// the path from createData for each MDX.
|
|
@@ -422,7 +372,7 @@ export default function pluginContentDocs(
|
|
|
422
372
|
loader: path.resolve(__dirname, './markdown/index.js'),
|
|
423
373
|
options: docsMarkdownOptions,
|
|
424
374
|
},
|
|
425
|
-
]),
|
|
375
|
+
].filter(Boolean),
|
|
426
376
|
};
|
|
427
377
|
}
|
|
428
378
|
|
package/src/lastUpdate.ts
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import shell from 'shelljs';
|
|
9
|
-
import
|
|
10
|
-
import path from 'path';
|
|
9
|
+
import logger from '@docusaurus/logger';
|
|
11
10
|
|
|
12
11
|
type FileLastUpdateData = {timestamp?: number; author?: string};
|
|
13
12
|
|
|
14
|
-
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),
|
|
13
|
+
const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),(.+)$/;
|
|
15
14
|
|
|
16
15
|
let showedGitRequirementError = false;
|
|
17
16
|
|
|
@@ -38,24 +37,23 @@ export async function getFileLastUpdate(
|
|
|
38
37
|
if (!shell.which('git')) {
|
|
39
38
|
if (!showedGitRequirementError) {
|
|
40
39
|
showedGitRequirementError = true;
|
|
41
|
-
|
|
40
|
+
logger.warn('Sorry, the docs plugin last update options require Git.');
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
return null;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.error(error);
|
|
46
|
+
const result = shell.exec(`git log -1 --format=%ct,%an ${filePath}`, {
|
|
47
|
+
silent: true,
|
|
48
|
+
});
|
|
49
|
+
if (result.code !== 0) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return getTimestampAndAuthor(result.stdout.trim());
|
|
55
|
+
} catch (e) {
|
|
56
|
+
logger.error(e);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
return null;
|
package/src/markdown/index.ts
CHANGED
|
@@ -7,20 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
import {linkify} from './linkify';
|
|
9
9
|
import {DocsMarkdownOption} from '../types';
|
|
10
|
+
import type {LoaderContext} from 'webpack';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const markdownLoader: Loader = function (source) {
|
|
18
|
-
const fileString = source as string;
|
|
12
|
+
export default function markdownLoader(
|
|
13
|
+
this: LoaderContext<DocsMarkdownOption>,
|
|
14
|
+
source: string,
|
|
15
|
+
): void {
|
|
16
|
+
const fileString = source;
|
|
19
17
|
const callback = this.async();
|
|
20
|
-
const options = this.getOptions()
|
|
18
|
+
const options = this.getOptions();
|
|
21
19
|
return (
|
|
22
20
|
callback && callback(null, linkify(fileString, this.resourcePath, options))
|
|
23
21
|
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default markdownLoader;
|
|
22
|
+
}
|
package/src/numberPrefix.ts
CHANGED
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {NumberPrefixParser} from './types';
|
|
8
|
+
import type {NumberPrefixParser} from './types';
|
|
9
9
|
|
|
10
10
|
// Best-effort to avoid parsing some patterns as number prefix
|
|
11
11
|
const IgnoredPrefixPatterns = (function () {
|
|
12
12
|
// ignore common date-like patterns: https://github.com/facebook/docusaurus/issues/4640
|
|
13
|
-
const DateLikePrefixRegex =
|
|
13
|
+
const DateLikePrefixRegex =
|
|
14
|
+
/^((\d{2}|\d{4})[-_.]\d{2}([-_.](\d{2}|\d{4}))?)(.*)$/;
|
|
14
15
|
|
|
15
16
|
// ignore common versioning patterns: https://github.com/facebook/docusaurus/issues/4653
|
|
16
17
|
// note: we could try to parse float numbers in filenames but that is probably not worth it
|
|
@@ -23,7 +24,8 @@ const IgnoredPrefixPatterns = (function () {
|
|
|
23
24
|
);
|
|
24
25
|
})();
|
|
25
26
|
|
|
26
|
-
const NumberPrefixRegex =
|
|
27
|
+
const NumberPrefixRegex =
|
|
28
|
+
/^(?<numberPrefix>\d+)(?<separator>\s*[-_.]+\s*)(?<suffix>.*)$/;
|
|
27
29
|
|
|
28
30
|
// 0-myDoc => {filename: myDoc, numberPrefix: 0}
|
|
29
31
|
// 003 - myDoc => {filename: myDoc, numberPrefix: 3}
|
package/src/options.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import type {PluginOptions} from './types';
|
|
8
9
|
import {
|
|
9
10
|
Joi,
|
|
10
11
|
RemarkPluginsSchema,
|
|
@@ -12,10 +13,15 @@ import {
|
|
|
12
13
|
AdmonitionsSchema,
|
|
13
14
|
URISchema,
|
|
14
15
|
} from '@docusaurus/utils-validation';
|
|
15
|
-
import {
|
|
16
|
-
|
|
16
|
+
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
OptionValidationContext,
|
|
20
|
+
ValidationResult,
|
|
21
|
+
} from '@docusaurus/types';
|
|
22
|
+
import logger from '@docusaurus/logger';
|
|
17
23
|
import admonitions from 'remark-admonitions';
|
|
18
|
-
import {DefaultSidebarItemsGenerator} from './
|
|
24
|
+
import {DefaultSidebarItemsGenerator} from './sidebars/generator';
|
|
19
25
|
import {
|
|
20
26
|
DefaultNumberPrefixParser,
|
|
21
27
|
DisabledNumberPrefixParser,
|
|
@@ -24,12 +30,16 @@ import {
|
|
|
24
30
|
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
25
31
|
path: 'docs', // Path to data on filesystem, relative to site dir.
|
|
26
32
|
routeBasePath: 'docs', // URL Route.
|
|
27
|
-
|
|
33
|
+
tagsBasePath: 'tags', // URL Tags Route.
|
|
28
34
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
|
35
|
+
exclude: GlobExcludeDefault,
|
|
29
36
|
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
|
30
37
|
numberPrefixParser: DefaultNumberPrefixParser,
|
|
31
38
|
docLayoutComponent: '@theme/DocPage',
|
|
32
39
|
docItemComponent: '@theme/DocItem',
|
|
40
|
+
docTagDocListComponent: '@theme/DocTagDocListPage',
|
|
41
|
+
docTagsListComponent: '@theme/DocTagsListPage',
|
|
42
|
+
docCategoryGeneratedIndexComponent: '@theme/DocCategoryGeneratedIndexPage',
|
|
33
43
|
remarkPlugins: [],
|
|
34
44
|
rehypePlugins: [],
|
|
35
45
|
beforeDefaultRemarkPlugins: [],
|
|
@@ -43,12 +53,16 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
|
43
53
|
versions: {},
|
|
44
54
|
editCurrentVersion: false,
|
|
45
55
|
editLocalizedFiles: false,
|
|
56
|
+
sidebarCollapsible: true,
|
|
57
|
+
sidebarCollapsed: true,
|
|
46
58
|
};
|
|
47
59
|
|
|
48
60
|
const VersionOptionsSchema = Joi.object({
|
|
49
61
|
path: Joi.string().allow('').optional(),
|
|
50
62
|
label: Joi.string().optional(),
|
|
51
63
|
banner: Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
|
|
64
|
+
badge: Joi.boolean().optional(),
|
|
65
|
+
className: Joi.string().optional(),
|
|
52
66
|
});
|
|
53
67
|
|
|
54
68
|
const VersionsOptionsSchema = Joi.object()
|
|
@@ -64,8 +78,14 @@ export const OptionsSchema = Joi.object({
|
|
|
64
78
|
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
|
65
79
|
// .allow('') ""
|
|
66
80
|
.default(DEFAULT_OPTIONS.routeBasePath),
|
|
67
|
-
|
|
81
|
+
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
|
82
|
+
homePageId: Joi.any().forbidden().messages({
|
|
83
|
+
'any.unknown':
|
|
84
|
+
'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
|
|
85
|
+
}),
|
|
86
|
+
|
|
68
87
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
88
|
+
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
|
69
89
|
sidebarPath: Joi.alternatives().try(
|
|
70
90
|
Joi.boolean().invalid(true),
|
|
71
91
|
Joi.string(),
|
|
@@ -73,6 +93,8 @@ export const OptionsSchema = Joi.object({
|
|
|
73
93
|
sidebarItemsGenerator: Joi.function().default(
|
|
74
94
|
() => DEFAULT_OPTIONS.sidebarItemsGenerator,
|
|
75
95
|
),
|
|
96
|
+
sidebarCollapsible: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsible),
|
|
97
|
+
sidebarCollapsed: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsed),
|
|
76
98
|
numberPrefixParser: Joi.alternatives()
|
|
77
99
|
.try(
|
|
78
100
|
Joi.function(),
|
|
@@ -86,6 +108,15 @@ export const OptionsSchema = Joi.object({
|
|
|
86
108
|
.default(() => DEFAULT_OPTIONS.numberPrefixParser),
|
|
87
109
|
docLayoutComponent: Joi.string().default(DEFAULT_OPTIONS.docLayoutComponent),
|
|
88
110
|
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
|
111
|
+
docTagsListComponent: Joi.string().default(
|
|
112
|
+
DEFAULT_OPTIONS.docTagsListComponent,
|
|
113
|
+
),
|
|
114
|
+
docTagDocListComponent: Joi.string().default(
|
|
115
|
+
DEFAULT_OPTIONS.docTagDocListComponent,
|
|
116
|
+
),
|
|
117
|
+
docCategoryGeneratedIndexComponent: Joi.string().default(
|
|
118
|
+
DEFAULT_OPTIONS.docCategoryGeneratedIndexComponent,
|
|
119
|
+
),
|
|
89
120
|
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
|
90
121
|
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
|
|
91
122
|
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
|
|
@@ -112,16 +143,26 @@ export const OptionsSchema = Joi.object({
|
|
|
112
143
|
|
|
113
144
|
export function validateOptions({
|
|
114
145
|
validate,
|
|
115
|
-
options,
|
|
146
|
+
options: userOptions,
|
|
116
147
|
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (options.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
148
|
+
let options = userOptions;
|
|
149
|
+
|
|
150
|
+
if (options.sidebarCollapsible === false) {
|
|
151
|
+
// When sidebarCollapsible=false and sidebarCollapsed=undefined, we don't want to have the inconsistency warning
|
|
152
|
+
// We let options.sidebarCollapsible become the default value for options.sidebarCollapsed
|
|
153
|
+
if (typeof options.sidebarCollapsed === 'undefined') {
|
|
154
|
+
options = {
|
|
155
|
+
...options,
|
|
156
|
+
sidebarCollapsed: false,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (options.sidebarCollapsed) {
|
|
160
|
+
logger.warn`The docs plugin config is inconsistent. It does not make sense to use code=${'sidebarCollapsible: false'} and code=${'sidebarCollapsed: true'} at the same time. code=${'sidebarCollapsed: true'} will be ignored.`;
|
|
161
|
+
options = {
|
|
162
|
+
...options,
|
|
163
|
+
sidebarCollapsed: false,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
125
166
|
}
|
|
126
167
|
|
|
127
168
|
const normalizedOptions = validate(OptionsSchema, options);
|