@docusaurus/plugin-content-docs 2.0.0-beta.15d451942 → 2.0.0-beta.18
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 +35 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +37 -51
- package/lib/client/docsClientUtils.d.ts +6 -26
- package/lib/client/docsClientUtils.js +28 -34
- package/lib/{theme/hooks/useDocs.d.ts → client/index.d.ts} +4 -3
- package/lib/{theme/hooks/useDocs.js → client/index.js} +28 -25
- package/lib/docs.d.ts +31 -4
- package/lib/docs.js +160 -54
- package/{src/__tests__/__fixtures__/simple-site/docusaurus.config.js → lib/frontMatter.d.ts} +4 -8
- package/lib/{docFrontMatter.js → frontMatter.js} +13 -6
- package/lib/globalData.d.ts +2 -2
- package/lib/globalData.js +32 -3
- package/lib/index.d.ts +4 -3
- package/lib/index.js +123 -136
- package/lib/lastUpdate.d.ts +4 -6
- package/lib/lastUpdate.js +22 -26
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.d.ts +1 -1
- package/lib/markdown/linkify.js +7 -3
- package/lib/numberPrefix.d.ts +1 -1
- package/lib/numberPrefix.js +16 -21
- package/lib/options.d.ts +3 -5
- package/lib/options.js +55 -19
- package/lib/props.d.ts +7 -2
- package/lib/props.js +70 -14
- package/lib/routes.d.ts +28 -0
- package/lib/routes.js +110 -0
- package/lib/server-export.d.ts +8 -0
- package/lib/server-export.js +23 -0
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -6
- package/lib/sidebars/generator.js +209 -0
- package/lib/sidebars/index.d.ts +13 -0
- package/lib/sidebars/index.js +94 -0
- package/lib/sidebars/normalization.d.ts +13 -0
- package/lib/sidebars/normalization.js +55 -0
- package/lib/sidebars/postProcessor.d.ts +8 -0
- package/lib/sidebars/postProcessor.js +65 -0
- package/lib/sidebars/processor.d.ts +10 -0
- package/lib/sidebars/processor.js +79 -0
- package/lib/sidebars/types.d.ts +174 -0
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
- package/lib/sidebars/utils.d.ts +54 -0
- package/lib/sidebars/utils.js +255 -0
- package/lib/sidebars/validation.d.ts +11 -0
- package/lib/sidebars/validation.js +138 -0
- package/lib/slug.d.ts +6 -4
- package/lib/slug.js +29 -19
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js → lib/tags.d.ts} +2 -8
- package/lib/tags.js +21 -0
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +89 -49
- package/lib/types.d.ts +60 -130
- package/lib/versions.d.ts +29 -4
- package/lib/versions.js +134 -97
- package/package.json +30 -26
- package/src/categoryGeneratedIndex.ts +55 -0
- package/src/cli.ts +47 -63
- package/src/client/docsClientUtils.ts +38 -73
- package/src/{theme/hooks/useDocs.ts → client/index.ts} +16 -11
- package/{types.d.ts → src/deps.d.ts} +1 -1
- package/src/docs.ts +212 -46
- package/src/{docFrontMatter.ts → frontMatter.ts} +21 -26
- package/src/globalData.ts +53 -3
- package/src/index.ts +168 -178
- package/src/lastUpdate.ts +26 -33
- package/src/markdown/index.ts +10 -16
- package/src/markdown/linkify.ts +6 -2
- package/src/numberPrefix.ts +19 -26
- package/src/options.ts +60 -32
- package/src/plugin-content-docs.d.ts +263 -40
- package/src/props.ts +105 -21
- package/src/routes.ts +185 -0
- package/src/server-export.ts +24 -0
- package/src/sidebars/README.md +9 -0
- package/src/sidebars/generator.ts +292 -0
- package/src/sidebars/index.ts +120 -0
- package/src/sidebars/normalization.ts +85 -0
- package/src/sidebars/postProcessor.ts +89 -0
- package/src/sidebars/processor.ts +120 -0
- package/src/sidebars/types.ts +274 -0
- package/src/sidebars/utils.ts +388 -0
- package/src/sidebars/validation.ts +174 -0
- package/src/slug.ts +40 -23
- package/src/tags.ts +19 -0
- package/src/translations.ts +124 -66
- package/src/types.ts +67 -187
- package/src/versions.ts +205 -110
- package/lib/.tsbuildinfo +0 -4717
- package/lib/docFrontMatter.d.ts +0 -21
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -42
- package/lib/sidebars.js +0 -309
- 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 -67
- package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -52
- 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/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/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/docusaurus.config.js +0 -14
- 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 -1907
- 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 -204
- package/src/__tests__/docs.test.ts +0 -875
- package/src/__tests__/index.test.ts +0 -1831
- package/src/__tests__/lastUpdate.test.ts +0 -68
- package/src/__tests__/numberPrefix.test.ts +0 -199
- package/src/__tests__/options.test.ts +0 -232
- package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
- package/src/__tests__/sidebars.test.ts +0 -638
- package/src/__tests__/slug.test.ts +0 -109
- package/src/__tests__/translations.test.ts +0 -159
- package/src/__tests__/versions.test.ts +0 -718
- package/src/client/__tests__/docsClientUtils.test.ts +0 -372
- 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 -489
- package/tsconfig.json +0 -9
package/lib/slug.js
CHANGED
|
@@ -8,33 +8,43 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const utils_1 = require("@docusaurus/utils");
|
|
10
10
|
const numberPrefix_1 = require("./numberPrefix");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (baseSlug.startsWith('/')) {
|
|
15
|
-
slug = baseSlug;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
11
|
+
const docs_1 = require("./docs");
|
|
12
|
+
function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes = true, numberPrefixParser = numberPrefix_1.DefaultNumberPrefixParser, }) {
|
|
13
|
+
function getDirNameSlug() {
|
|
18
14
|
const dirNameStripped = stripDirNumberPrefixes
|
|
19
|
-
? numberPrefix_1.stripPathNumberPrefixes(
|
|
20
|
-
:
|
|
21
|
-
const resolveDirname =
|
|
15
|
+
? (0, numberPrefix_1.stripPathNumberPrefixes)(sourceDirName, numberPrefixParser)
|
|
16
|
+
: sourceDirName;
|
|
17
|
+
const resolveDirname = sourceDirName === '.'
|
|
22
18
|
? '/'
|
|
23
|
-
: utils_1.addLeadingSlash(utils_1.addTrailingSlash(dirNameStripped));
|
|
24
|
-
|
|
19
|
+
: (0, utils_1.addLeadingSlash)((0, utils_1.addTrailingSlash)(dirNameStripped));
|
|
20
|
+
return resolveDirname;
|
|
21
|
+
}
|
|
22
|
+
function computeSlug() {
|
|
23
|
+
if (frontMatterSlug?.startsWith('/')) {
|
|
24
|
+
return frontMatterSlug;
|
|
25
|
+
}
|
|
26
|
+
const dirNameSlug = getDirNameSlug();
|
|
27
|
+
if (!frontMatterSlug &&
|
|
28
|
+
(0, docs_1.isCategoryIndex)((0, docs_1.toCategoryIndexMatcherParam)({ source, sourceDirName }))) {
|
|
29
|
+
return dirNameSlug;
|
|
30
|
+
}
|
|
31
|
+
const baseSlug = frontMatterSlug || baseID;
|
|
32
|
+
return (0, utils_1.resolvePathname)(baseSlug, getDirNameSlug());
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
function ensureValidSlug(slug) {
|
|
35
|
+
if (!(0, utils_1.isValidPathname)(slug)) {
|
|
36
|
+
throw new Error(`We couldn't compute a valid slug for document with ID "${baseID}" in "${sourceDirName}" directory.
|
|
37
|
+
The slug we computed looks invalid: ${slug}.
|
|
38
|
+
Maybe your slug front matter is incorrect or there are special characters in the file path?
|
|
39
|
+
By using front matter to set a custom slug, you should be able to fix this error:
|
|
31
40
|
|
|
32
|
-
Example =>
|
|
33
41
|
---
|
|
34
42
|
slug: /my/customDocPath
|
|
35
43
|
---
|
|
36
44
|
`);
|
|
45
|
+
}
|
|
46
|
+
return slug;
|
|
37
47
|
}
|
|
38
|
-
return
|
|
48
|
+
return ensureValidSlug(computeSlug());
|
|
39
49
|
}
|
|
40
50
|
exports.default = getSlug;
|
|
@@ -4,11 +4,5 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
title: 'My Site',
|
|
10
|
-
tagline: 'The tagline of my site',
|
|
11
|
-
url: 'https://your-docusaurus-test-site.com',
|
|
12
|
-
baseUrl: '/',
|
|
13
|
-
favicon: 'img/favicon.ico',
|
|
14
|
-
};
|
|
7
|
+
import type { VersionTags, DocMetadata } from './types';
|
|
8
|
+
export declare function getVersionTags(docs: DocMetadata[]): VersionTags;
|
package/lib/tags.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getVersionTags = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
13
|
+
function getVersionTags(docs) {
|
|
14
|
+
const groups = (0, utils_1.groupTaggedItems)(docs, (doc) => doc.tags);
|
|
15
|
+
return lodash_1.default.mapValues(groups, (group) => ({
|
|
16
|
+
name: group.tag.label,
|
|
17
|
+
docIds: group.items.map((item) => item.id),
|
|
18
|
+
permalink: group.tag.permalink,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
exports.getVersionTags = getVersionTags;
|
package/lib/translations.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import { LoadedContent } from './types';
|
|
8
|
-
import { TranslationFile, TranslationFiles } from '@docusaurus/types';
|
|
7
|
+
import type { LoadedContent } from './types';
|
|
8
|
+
import type { TranslationFile, TranslationFiles } from '@docusaurus/types';
|
|
9
9
|
export declare function getLoadedContentTranslationFiles(loadedContent: LoadedContent): TranslationFiles;
|
|
10
10
|
export declare function translateLoadedContent(loadedContent: LoadedContent, translationFiles: TranslationFile[]): LoadedContent;
|
package/lib/translations.js
CHANGED
|
@@ -7,19 +7,18 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.translateLoadedContent = exports.getLoadedContentTranslationFiles = void 0;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const utils_1 = require("
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
+
const utils_1 = require("./sidebars/utils");
|
|
13
|
+
const utils_2 = require("@docusaurus/utils");
|
|
13
14
|
const constants_1 = require("./constants");
|
|
14
15
|
function getVersionFileName(versionName) {
|
|
15
16
|
if (versionName === constants_1.CURRENT_VERSION_NAME) {
|
|
16
17
|
return versionName;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `version-${versionName}`;
|
|
22
|
-
}
|
|
19
|
+
// I don't like this "version-" prefix,
|
|
20
|
+
// but it's for consistency with site/versioned_docs
|
|
21
|
+
return `version-${versionName}`;
|
|
23
22
|
}
|
|
24
23
|
// TODO legacy, the sidebar name is like "version-2.0.0-alpha.66/docs"
|
|
25
24
|
// input: "version-2.0.0-alpha.66/docs"
|
|
@@ -32,8 +31,8 @@ function getNormalizedSidebarName({ versionName, sidebarName, }) {
|
|
|
32
31
|
return rest.join('/');
|
|
33
32
|
}
|
|
34
33
|
/*
|
|
35
|
-
// Do we need to translate doc
|
|
36
|
-
// It seems translating
|
|
34
|
+
// Do we need to translate doc metadata?
|
|
35
|
+
// It seems translating front matter labels is good enough
|
|
37
36
|
function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
38
37
|
return {
|
|
39
38
|
[`${doc.unversionedId}.title`]: {
|
|
@@ -44,7 +43,8 @@ function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
|
44
43
|
? {
|
|
45
44
|
[`${doc.unversionedId}.sidebar_label`]: {
|
|
46
45
|
message: doc.sidebar_label,
|
|
47
|
-
description:
|
|
46
|
+
description:
|
|
47
|
+
`The sidebar label for doc with id=${doc.unversionedId}`,
|
|
48
48
|
},
|
|
49
49
|
}
|
|
50
50
|
: undefined),
|
|
@@ -74,44 +74,86 @@ function translateDocs(
|
|
|
74
74
|
}
|
|
75
75
|
*/
|
|
76
76
|
function getSidebarTranslationFileContent(sidebar, sidebarName) {
|
|
77
|
-
const categories =
|
|
78
|
-
const categoryContent =
|
|
79
|
-
|
|
80
|
-
.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
const categories = (0, utils_1.collectSidebarCategories)(sidebar);
|
|
78
|
+
const categoryContent = Object.fromEntries(categories.flatMap((category) => {
|
|
79
|
+
const entries = [];
|
|
80
|
+
entries.push([
|
|
81
|
+
`sidebar.${sidebarName}.category.${category.label}`,
|
|
82
|
+
{
|
|
83
|
+
message: category.label,
|
|
84
|
+
description: `The label for category ${category.label} in sidebar ${sidebarName}`,
|
|
85
|
+
},
|
|
86
|
+
]);
|
|
87
|
+
if (category.link?.type === 'generated-index') {
|
|
88
|
+
if (category.link.title) {
|
|
89
|
+
entries.push([
|
|
90
|
+
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`,
|
|
91
|
+
{
|
|
92
|
+
message: category.link.title,
|
|
93
|
+
description: `The generated-index page title for category ${category.label} in sidebar ${sidebarName}`,
|
|
94
|
+
},
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
if (category.link.description) {
|
|
98
|
+
entries.push([
|
|
99
|
+
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`,
|
|
100
|
+
{
|
|
101
|
+
message: category.link.description,
|
|
102
|
+
description: `The generated-index page description for category ${category.label} in sidebar ${sidebarName}`,
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return entries;
|
|
108
|
+
}));
|
|
109
|
+
const links = (0, utils_1.collectSidebarLinks)(sidebar);
|
|
110
|
+
const linksContent = Object.fromEntries(links.map((link) => [
|
|
111
|
+
`sidebar.${sidebarName}.link.${link.label}`,
|
|
112
|
+
{
|
|
113
|
+
message: link.label,
|
|
114
|
+
description: `The label for link ${link.label} in sidebar ${sidebarName}, linking to ${link.href}`,
|
|
115
|
+
},
|
|
116
|
+
]));
|
|
117
|
+
return (0, utils_2.mergeTranslations)([categoryContent, linksContent]);
|
|
94
118
|
}
|
|
95
119
|
function translateSidebar({ sidebar, sidebarName, sidebarsTranslations, }) {
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
function transformSidebarCategoryLink(category) {
|
|
121
|
+
if (!category.link) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (category.link.type === 'generated-index') {
|
|
125
|
+
const title = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`]?.message ?? category.link.title;
|
|
126
|
+
const description = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`]?.message ?? category.link.description;
|
|
127
|
+
return {
|
|
128
|
+
...category.link,
|
|
129
|
+
title,
|
|
130
|
+
description,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return category.link;
|
|
134
|
+
}
|
|
135
|
+
return (0, utils_1.transformSidebarItems)(sidebar, (item) => {
|
|
98
136
|
if (item.type === 'category') {
|
|
137
|
+
const link = transformSidebarCategoryLink(item);
|
|
99
138
|
return {
|
|
100
139
|
...item,
|
|
101
|
-
label:
|
|
140
|
+
label: sidebarsTranslations[`sidebar.${sidebarName}.category.${item.label}`]
|
|
141
|
+
?.message ?? item.label,
|
|
142
|
+
...(link && { link }),
|
|
102
143
|
};
|
|
103
144
|
}
|
|
104
145
|
if (item.type === 'link') {
|
|
105
146
|
return {
|
|
106
147
|
...item,
|
|
107
|
-
label:
|
|
148
|
+
label: sidebarsTranslations[`sidebar.${sidebarName}.link.${item.label}`]
|
|
149
|
+
?.message ?? item.label,
|
|
108
150
|
};
|
|
109
151
|
}
|
|
110
152
|
return item;
|
|
111
153
|
});
|
|
112
154
|
}
|
|
113
155
|
function getSidebarsTranslations(version) {
|
|
114
|
-
return
|
|
156
|
+
return (0, utils_2.mergeTranslations)(Object.entries(version.sidebars).map(([sidebarName, sidebar]) => {
|
|
115
157
|
const normalizedSidebarName = getNormalizedSidebarName({
|
|
116
158
|
sidebarName,
|
|
117
159
|
versionName: version.versionName,
|
|
@@ -120,16 +162,14 @@ function getSidebarsTranslations(version) {
|
|
|
120
162
|
}));
|
|
121
163
|
}
|
|
122
164
|
function translateSidebars(version, sidebarsTranslations) {
|
|
123
|
-
return lodash_1.mapValues(version.sidebars, (sidebar, sidebarName) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
sidebarName
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
});
|
|
165
|
+
return lodash_1.default.mapValues(version.sidebars, (sidebar, sidebarName) => translateSidebar({
|
|
166
|
+
sidebar,
|
|
167
|
+
sidebarName: getNormalizedSidebarName({
|
|
168
|
+
sidebarName,
|
|
169
|
+
versionName: version.versionName,
|
|
170
|
+
}),
|
|
171
|
+
sidebarsTranslations,
|
|
172
|
+
}));
|
|
133
173
|
}
|
|
134
174
|
function getVersionTranslationFiles(version) {
|
|
135
175
|
const versionTranslations = {
|
|
@@ -139,11 +179,12 @@ function getVersionTranslationFiles(version) {
|
|
|
139
179
|
},
|
|
140
180
|
};
|
|
141
181
|
const sidebarsTranslations = getSidebarsTranslations(version);
|
|
142
|
-
// const docsTranslations: TranslationFileContent =
|
|
182
|
+
// const docsTranslations: TranslationFileContent =
|
|
183
|
+
// getDocsTranslations(version);
|
|
143
184
|
return [
|
|
144
185
|
{
|
|
145
186
|
path: getVersionFileName(version.versionName),
|
|
146
|
-
content:
|
|
187
|
+
content: (0, utils_2.mergeTranslations)([
|
|
147
188
|
versionTranslations,
|
|
148
189
|
sidebarsTranslations,
|
|
149
190
|
// docsTranslations,
|
|
@@ -152,17 +193,16 @@ function getVersionTranslationFiles(version) {
|
|
|
152
193
|
];
|
|
153
194
|
}
|
|
154
195
|
function translateVersion(version, translationFiles) {
|
|
155
|
-
var _a;
|
|
156
196
|
const versionTranslations = translationFiles[getVersionFileName(version.versionName)].content;
|
|
157
197
|
return {
|
|
158
198
|
...version,
|
|
159
|
-
versionLabel:
|
|
199
|
+
versionLabel: versionTranslations['version.label']?.message ?? version.versionLabel,
|
|
160
200
|
sidebars: translateSidebars(version, versionTranslations),
|
|
161
201
|
// docs: translateDocs(version.docs, versionTranslations),
|
|
162
202
|
};
|
|
163
203
|
}
|
|
164
204
|
function getVersionsTranslationFiles(versions) {
|
|
165
|
-
return
|
|
205
|
+
return versions.flatMap(getVersionTranslationFiles);
|
|
166
206
|
}
|
|
167
207
|
function translateVersions(versions, translationFiles) {
|
|
168
208
|
return versions.map((version) => translateVersion(version, translationFiles));
|
|
@@ -172,7 +212,7 @@ function getLoadedContentTranslationFiles(loadedContent) {
|
|
|
172
212
|
}
|
|
173
213
|
exports.getLoadedContentTranslationFiles = getLoadedContentTranslationFiles;
|
|
174
214
|
function translateLoadedContent(loadedContent, translationFiles) {
|
|
175
|
-
const translationFilesMap = lodash_1.keyBy(translationFiles, (f) => f.path);
|
|
215
|
+
const translationFilesMap = lodash_1.default.keyBy(translationFiles, (f) => f.path);
|
|
176
216
|
return {
|
|
177
217
|
loadedVersions: translateVersions(loadedContent.loadedVersions, translationFilesMap),
|
|
178
218
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
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
|
-
import type {
|
|
8
|
-
import {
|
|
7
|
+
import type { Sidebars } from './sidebars/types';
|
|
8
|
+
import type { Tag, FrontMatterTag, BrokenMarkdownLink, ContentPaths } from '@docusaurus/utils';
|
|
9
|
+
import type { VersionBanner } from '@docusaurus/plugin-content-docs';
|
|
9
10
|
export declare type DocFile = {
|
|
10
11
|
contentPath: string;
|
|
11
12
|
filePath: string;
|
|
@@ -13,135 +14,66 @@ export declare type DocFile = {
|
|
|
13
14
|
content: string;
|
|
14
15
|
lastUpdate: LastUpdateData;
|
|
15
16
|
};
|
|
16
|
-
export declare type VersionName = string;
|
|
17
17
|
export declare type VersionMetadata = ContentPaths & {
|
|
18
|
-
versionName:
|
|
18
|
+
versionName: string;
|
|
19
19
|
versionLabel: string;
|
|
20
20
|
versionPath: string;
|
|
21
|
+
tagsPath: string;
|
|
21
22
|
versionEditUrl?: string | undefined;
|
|
22
23
|
versionEditUrlLocalized?: string | undefined;
|
|
24
|
+
versionBanner: VersionBanner | null;
|
|
25
|
+
versionBadge: boolean;
|
|
26
|
+
versionClassName: string;
|
|
23
27
|
isLast: boolean;
|
|
24
28
|
sidebarFilePath: string | false | undefined;
|
|
25
29
|
routePriority: number | undefined;
|
|
26
30
|
};
|
|
27
|
-
export declare type EditUrlFunction = (editUrlParams: {
|
|
28
|
-
version: string;
|
|
29
|
-
versionDocsDirPath: string;
|
|
30
|
-
docPath: string;
|
|
31
|
-
permalink: string;
|
|
32
|
-
locale: string;
|
|
33
|
-
}) => string | undefined;
|
|
34
|
-
export declare type MetadataOptions = {
|
|
35
|
-
routeBasePath: string;
|
|
36
|
-
homePageId?: string;
|
|
37
|
-
editUrl?: string | EditUrlFunction;
|
|
38
|
-
editCurrentVersion: boolean;
|
|
39
|
-
editLocalizedFiles: boolean;
|
|
40
|
-
showLastUpdateTime?: boolean;
|
|
41
|
-
showLastUpdateAuthor?: boolean;
|
|
42
|
-
numberPrefixParser: NumberPrefixParser;
|
|
43
|
-
};
|
|
44
|
-
export declare type PathOptions = {
|
|
45
|
-
path: string;
|
|
46
|
-
sidebarPath?: string | false | undefined;
|
|
47
|
-
};
|
|
48
|
-
export declare type VersionOptions = {
|
|
49
|
-
path?: string;
|
|
50
|
-
label?: string;
|
|
51
|
-
};
|
|
52
|
-
export declare type VersionsOptions = {
|
|
53
|
-
lastVersion?: string;
|
|
54
|
-
versions: Record<string, VersionOptions>;
|
|
55
|
-
onlyIncludeVersions?: string[];
|
|
56
|
-
};
|
|
57
|
-
export declare type PluginOptions = MetadataOptions & PathOptions & VersionsOptions & RemarkAndRehypePluginOptions & {
|
|
58
|
-
id: string;
|
|
59
|
-
include: string[];
|
|
60
|
-
docLayoutComponent: string;
|
|
61
|
-
docItemComponent: string;
|
|
62
|
-
admonitions: Record<string, unknown>;
|
|
63
|
-
disableVersioning: boolean;
|
|
64
|
-
excludeNextVersionDocs?: boolean;
|
|
65
|
-
includeCurrentVersion: boolean;
|
|
66
|
-
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
|
67
|
-
};
|
|
68
|
-
export declare type SidebarItemBase = {
|
|
69
|
-
customProps?: Record<string, unknown>;
|
|
70
|
-
};
|
|
71
|
-
export declare type SidebarItemDoc = SidebarItemBase & {
|
|
72
|
-
type: 'doc' | 'ref';
|
|
73
|
-
label?: string;
|
|
74
|
-
id: string;
|
|
75
|
-
};
|
|
76
|
-
export declare type SidebarItemLink = SidebarItemBase & {
|
|
77
|
-
type: 'link';
|
|
78
|
-
href: string;
|
|
79
|
-
label: string;
|
|
80
|
-
};
|
|
81
|
-
export declare type SidebarItemCategory = SidebarItemBase & {
|
|
82
|
-
type: 'category';
|
|
83
|
-
label: string;
|
|
84
|
-
items: SidebarItem[];
|
|
85
|
-
collapsed: boolean;
|
|
86
|
-
};
|
|
87
|
-
export declare type UnprocessedSidebarItemAutogenerated = {
|
|
88
|
-
type: 'autogenerated';
|
|
89
|
-
dirName: string;
|
|
90
|
-
};
|
|
91
|
-
export declare type UnprocessedSidebarItemCategory = SidebarItemBase & {
|
|
92
|
-
type: 'category';
|
|
93
|
-
label: string;
|
|
94
|
-
items: UnprocessedSidebarItem[];
|
|
95
|
-
collapsed: boolean;
|
|
96
|
-
};
|
|
97
|
-
export declare type UnprocessedSidebarItem = SidebarItemDoc | SidebarItemLink | UnprocessedSidebarItemCategory | UnprocessedSidebarItemAutogenerated;
|
|
98
|
-
export declare type UnprocessedSidebar = UnprocessedSidebarItem[];
|
|
99
|
-
export declare type UnprocessedSidebars = Record<string, UnprocessedSidebar>;
|
|
100
|
-
export declare type SidebarItem = SidebarItemDoc | SidebarItemLink | SidebarItemCategory;
|
|
101
|
-
export declare type Sidebar = SidebarItem[];
|
|
102
|
-
export declare type SidebarItemType = SidebarItem['type'];
|
|
103
|
-
export declare type Sidebars = Record<string, Sidebar>;
|
|
104
|
-
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
105
|
-
export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
|
|
106
|
-
export declare type SidebarItemsGeneratorArgs = {
|
|
107
|
-
item: UnprocessedSidebarItemAutogenerated;
|
|
108
|
-
version: SidebarItemsGeneratorVersion;
|
|
109
|
-
docs: SidebarItemsGeneratorDoc[];
|
|
110
|
-
numberPrefixParser: NumberPrefixParser;
|
|
111
|
-
};
|
|
112
|
-
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<SidebarItem[]>;
|
|
113
|
-
export declare type SidebarItemsGeneratorOptionArgs = {
|
|
114
|
-
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
|
115
|
-
} & SidebarItemsGeneratorArgs;
|
|
116
|
-
export declare type SidebarItemsGeneratorOption = (generatorArgs: SidebarItemsGeneratorOptionArgs) => Promise<SidebarItem[]>;
|
|
117
|
-
export declare type OrderMetadata = {
|
|
118
|
-
previous?: string;
|
|
119
|
-
next?: string;
|
|
120
|
-
sidebar?: string;
|
|
121
|
-
};
|
|
122
31
|
export declare type LastUpdateData = {
|
|
123
32
|
lastUpdatedAt?: number;
|
|
124
33
|
formattedLastUpdatedAt?: string;
|
|
125
34
|
lastUpdatedBy?: string;
|
|
126
35
|
};
|
|
127
|
-
export declare type
|
|
128
|
-
|
|
36
|
+
export declare type DocFrontMatter = {
|
|
37
|
+
id?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
tags?: FrontMatterTag[];
|
|
40
|
+
hide_title?: boolean;
|
|
41
|
+
hide_table_of_contents?: boolean;
|
|
42
|
+
keywords?: string[];
|
|
43
|
+
image?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
slug?: string;
|
|
46
|
+
sidebar_label?: string;
|
|
47
|
+
sidebar_position?: number;
|
|
48
|
+
sidebar_class_name?: string;
|
|
49
|
+
sidebar_custom_props?: {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
displayed_sidebar?: string | null;
|
|
53
|
+
pagination_label?: string;
|
|
54
|
+
custom_edit_url?: string | null;
|
|
55
|
+
parse_number_prefixes?: boolean;
|
|
56
|
+
toc_min_heading_level?: number;
|
|
57
|
+
toc_max_heading_level?: number;
|
|
58
|
+
pagination_next?: string | null;
|
|
59
|
+
pagination_prev?: string | null;
|
|
129
60
|
};
|
|
130
61
|
export declare type DocMetadataBase = LastUpdateData & {
|
|
131
|
-
version: VersionName;
|
|
132
|
-
unversionedId: string;
|
|
133
62
|
id: string;
|
|
134
|
-
|
|
63
|
+
unversionedId: string;
|
|
64
|
+
version: string;
|
|
135
65
|
title: string;
|
|
136
66
|
description: string;
|
|
137
67
|
source: string;
|
|
138
68
|
sourceDirName: string;
|
|
139
69
|
slug: string;
|
|
140
70
|
permalink: string;
|
|
141
|
-
sidebar_label?: string;
|
|
142
71
|
sidebarPosition?: number;
|
|
143
72
|
editUrl?: string | null;
|
|
144
|
-
|
|
73
|
+
tags: Tag[];
|
|
74
|
+
frontMatter: DocFrontMatter & {
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
145
77
|
};
|
|
146
78
|
export declare type DocNavLink = {
|
|
147
79
|
title: string;
|
|
@@ -152,44 +84,42 @@ export declare type DocMetadata = DocMetadataBase & {
|
|
|
152
84
|
previous?: DocNavLink;
|
|
153
85
|
next?: DocNavLink;
|
|
154
86
|
};
|
|
87
|
+
export declare type CategoryGeneratedIndexMetadata = {
|
|
88
|
+
title: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
slug: string;
|
|
91
|
+
permalink: string;
|
|
92
|
+
sidebar: string;
|
|
93
|
+
previous?: DocNavLink;
|
|
94
|
+
next?: DocNavLink;
|
|
95
|
+
image?: string;
|
|
96
|
+
keywords?: string | readonly string[];
|
|
97
|
+
};
|
|
155
98
|
export declare type SourceToPermalink = {
|
|
156
99
|
[source: string]: string;
|
|
157
100
|
};
|
|
101
|
+
export declare type VersionTag = {
|
|
102
|
+
name: string;
|
|
103
|
+
docIds: string[];
|
|
104
|
+
permalink: string;
|
|
105
|
+
};
|
|
106
|
+
export declare type VersionTags = {
|
|
107
|
+
[key: string]: VersionTag;
|
|
108
|
+
};
|
|
158
109
|
export declare type LoadedVersion = VersionMetadata & {
|
|
159
110
|
versionPath: string;
|
|
160
111
|
mainDocId: string;
|
|
161
112
|
docs: DocMetadata[];
|
|
162
113
|
sidebars: Sidebars;
|
|
163
|
-
|
|
114
|
+
categoryGeneratedIndices: CategoryGeneratedIndexMetadata[];
|
|
164
115
|
};
|
|
165
116
|
export declare type LoadedContent = {
|
|
166
117
|
loadedVersions: LoadedVersion[];
|
|
167
118
|
};
|
|
168
|
-
export declare type
|
|
169
|
-
id: string;
|
|
170
|
-
path: string;
|
|
171
|
-
sidebar: string | undefined;
|
|
172
|
-
};
|
|
173
|
-
export declare type GlobalVersion = {
|
|
174
|
-
name: VersionName;
|
|
175
|
-
label: string;
|
|
176
|
-
isLast: boolean;
|
|
177
|
-
path: string;
|
|
178
|
-
mainDocId: string;
|
|
179
|
-
docs: GlobalDoc[];
|
|
180
|
-
};
|
|
181
|
-
export declare type GlobalPluginData = {
|
|
182
|
-
path: string;
|
|
183
|
-
versions: GlobalVersion[];
|
|
184
|
-
};
|
|
185
|
-
export declare type BrokenMarkdownLink = IBrokenMarkdownLink<VersionMetadata>;
|
|
119
|
+
export declare type DocBrokenMarkdownLink = BrokenMarkdownLink<VersionMetadata>;
|
|
186
120
|
export declare type DocsMarkdownOption = {
|
|
187
121
|
versionsMetadata: VersionMetadata[];
|
|
188
122
|
siteDir: string;
|
|
189
123
|
sourceToPermalink: SourceToPermalink;
|
|
190
|
-
onBrokenMarkdownLink: (brokenMarkdownLink:
|
|
191
|
-
};
|
|
192
|
-
export declare type NumberPrefixParser = (filename: string) => {
|
|
193
|
-
filename: string;
|
|
194
|
-
numberPrefix?: number;
|
|
124
|
+
onBrokenMarkdownLink: (brokenMarkdownLink: DocBrokenMarkdownLink) => void;
|
|
195
125
|
};
|
package/lib/versions.d.ts
CHANGED
|
@@ -4,13 +4,38 @@
|
|
|
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
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import type { VersionMetadata } from './types';
|
|
8
|
+
import type { PluginOptions, VersionBanner } from '@docusaurus/plugin-content-docs';
|
|
9
|
+
import type { LoadContext } from '@docusaurus/types';
|
|
9
10
|
export declare function getVersionedDocsDirPath(siteDir: string, pluginId: string): string;
|
|
10
11
|
export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: string): string;
|
|
11
12
|
export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
|
|
13
|
+
export declare function readVersionsFile(siteDir: string, pluginId: string): Promise<string[] | null>;
|
|
14
|
+
export declare function readVersionNames(siteDir: string, options: Pick<PluginOptions, 'id' | 'disableVersioning' | 'includeCurrentVersion'>): Promise<string[]>;
|
|
15
|
+
export declare function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }: {
|
|
16
|
+
versionName: string;
|
|
17
|
+
versionNames: string[];
|
|
18
|
+
lastVersionName: string;
|
|
19
|
+
}): VersionBanner | null;
|
|
20
|
+
export declare function getVersionBanner({ versionName, versionNames, lastVersionName, options, }: {
|
|
21
|
+
versionName: string;
|
|
22
|
+
versionNames: string[];
|
|
23
|
+
lastVersionName: string;
|
|
24
|
+
options: Pick<PluginOptions, 'versions'>;
|
|
25
|
+
}): VersionBanner | null;
|
|
26
|
+
export declare function getVersionBadge({ versionName, versionNames, options, }: {
|
|
27
|
+
versionName: string;
|
|
28
|
+
versionNames: string[];
|
|
29
|
+
options: Pick<PluginOptions, 'versions'>;
|
|
30
|
+
}): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Filter versions according to provided options.
|
|
33
|
+
* Note: we preserve the order in which versions are provided;
|
|
34
|
+
* the order of the onlyIncludeVersions array does not matter
|
|
35
|
+
*/
|
|
36
|
+
export declare function filterVersions(versionNamesUnfiltered: string[], options: Pick<PluginOptions, 'onlyIncludeVersions'>): string[];
|
|
12
37
|
export declare function readVersionsMetadata({ context, options, }: {
|
|
13
38
|
context: Pick<LoadContext, 'siteDir' | 'baseUrl' | 'i18n'>;
|
|
14
|
-
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
15
|
-
}): VersionMetadata[]
|
|
39
|
+
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'tagsBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
40
|
+
}): Promise<VersionMetadata[]>;
|
|
16
41
|
export declare function getDocsDirPaths(versionMetadata: Pick<VersionMetadata, 'contentPath' | 'contentPathLocalized'>): [string, string];
|