@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/lib/slug.js
CHANGED
|
@@ -8,23 +8,33 @@
|
|
|
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 === null || frontmatterSlug === void 0 ? void 0 : frontmatterSlug.startsWith('/')) {
|
|
24
|
+
return frontmatterSlug;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const dirNameSlug = getDirNameSlug();
|
|
28
|
+
if (!frontmatterSlug && (0, docs_1.isConventionalDocIndex)({ source, sourceDirName })) {
|
|
29
|
+
return dirNameSlug;
|
|
30
|
+
}
|
|
31
|
+
const baseSlug = frontmatterSlug || baseID;
|
|
32
|
+
return (0, utils_1.resolvePathname)(baseSlug, getDirNameSlug());
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
function ensureValidSlug(slug) {
|
|
36
|
+
if (!(0, utils_1.isValidPathname)(slug)) {
|
|
37
|
+
throw new Error(`We couldn't compute a valid slug for document with id "${baseID}" in "${sourceDirName}" directory.
|
|
28
38
|
The slug we computed looks invalid: ${slug}.
|
|
29
39
|
Maybe your slug frontmatter is incorrect or you use weird chars in the file path?
|
|
30
40
|
By using the slug frontmatter, you should be able to fix this error, by using the slug of your choice:
|
|
@@ -34,7 +44,9 @@ Example =>
|
|
|
34
44
|
slug: /my/customDocPath
|
|
35
45
|
---
|
|
36
46
|
`);
|
|
47
|
+
}
|
|
48
|
+
return slug;
|
|
37
49
|
}
|
|
38
|
-
return
|
|
50
|
+
return ensureValidSlug(computeSlug());
|
|
39
51
|
}
|
|
40
52
|
exports.default = getSlug;
|
package/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/tags.d.ts}
RENAMED
|
@@ -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,20 @@
|
|
|
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 utils_1 = require("@docusaurus/utils");
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
function getVersionTags(docs) {
|
|
13
|
+
const groups = (0, utils_1.groupTaggedItems)(docs, (doc) => doc.tags);
|
|
14
|
+
return (0, lodash_1.mapValues)(groups, (group) => ({
|
|
15
|
+
name: group.tag.label,
|
|
16
|
+
docIds: group.items.map((item) => item.id),
|
|
17
|
+
permalink: group.tag.permalink,
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
exports.getVersionTags = getVersionTags;
|
|
@@ -9,27 +9,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActiveVersion = exports.useLatestVersion = exports.useVersions = exports.useActivePluginAndVersion = exports.useActivePlugin = exports.useDocsData = exports.useAllDocsData = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const router_1 = require("@docusaurus/router");
|
|
12
|
-
const useGlobalData_1 = tslib_1.__importStar(require("@docusaurus/useGlobalData"));
|
|
12
|
+
const useGlobalData_1 = (0, tslib_1.__importStar)(require("@docusaurus/useGlobalData"));
|
|
13
13
|
const docsClientUtils_1 = require("../../client/docsClientUtils");
|
|
14
|
+
// Important to use a constant object to avoid React useEffect executions etc...,
|
|
15
|
+
// see https://github.com/facebook/docusaurus/issues/5089
|
|
16
|
+
const StableEmptyObject = {};
|
|
14
17
|
// Not using useAllPluginInstancesData() because in blog-only mode, docs hooks are still used by the theme
|
|
15
18
|
// We need a fail-safe fallback when the docs plugin is not in use
|
|
16
19
|
const useAllDocsData = () => { var _a;
|
|
17
20
|
// useAllPluginInstancesData('docusaurus-plugin-content-docs');
|
|
18
|
-
return (_a = useGlobalData_1.default()['docusaurus-plugin-content-docs']) !== null && _a !== void 0 ? _a :
|
|
21
|
+
return (_a = (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs']) !== null && _a !== void 0 ? _a : StableEmptyObject; };
|
|
19
22
|
exports.useAllDocsData = useAllDocsData;
|
|
20
|
-
const useDocsData = (pluginId) => useGlobalData_1.usePluginData('docusaurus-plugin-content-docs', pluginId);
|
|
23
|
+
const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
|
|
21
24
|
exports.useDocsData = useDocsData;
|
|
22
25
|
const useActivePlugin = (options = {}) => {
|
|
23
|
-
const data = exports.useAllDocsData();
|
|
24
|
-
const { pathname } = router_1.useLocation();
|
|
25
|
-
return docsClientUtils_1.getActivePlugin(data, pathname, options);
|
|
26
|
+
const data = (0, exports.useAllDocsData)();
|
|
27
|
+
const { pathname } = (0, router_1.useLocation)();
|
|
28
|
+
return (0, docsClientUtils_1.getActivePlugin)(data, pathname, options);
|
|
26
29
|
};
|
|
27
30
|
exports.useActivePlugin = useActivePlugin;
|
|
28
31
|
const useActivePluginAndVersion = (options = {}) => {
|
|
29
|
-
const activePlugin = exports.useActivePlugin(options);
|
|
30
|
-
const { pathname } = router_1.useLocation();
|
|
32
|
+
const activePlugin = (0, exports.useActivePlugin)(options);
|
|
33
|
+
const { pathname } = (0, router_1.useLocation)();
|
|
31
34
|
if (activePlugin) {
|
|
32
|
-
const activeVersion = docsClientUtils_1.getActiveVersion(activePlugin.pluginData, pathname);
|
|
35
|
+
const activeVersion = (0, docsClientUtils_1.getActiveVersion)(activePlugin.pluginData, pathname);
|
|
33
36
|
return {
|
|
34
37
|
activePlugin,
|
|
35
38
|
activeVersion,
|
|
@@ -40,33 +43,33 @@ const useActivePluginAndVersion = (options = {}) => {
|
|
|
40
43
|
exports.useActivePluginAndVersion = useActivePluginAndVersion;
|
|
41
44
|
// versions are returned ordered (most recent first)
|
|
42
45
|
const useVersions = (pluginId) => {
|
|
43
|
-
const data = exports.useDocsData(pluginId);
|
|
46
|
+
const data = (0, exports.useDocsData)(pluginId);
|
|
44
47
|
return data.versions;
|
|
45
48
|
};
|
|
46
49
|
exports.useVersions = useVersions;
|
|
47
50
|
const useLatestVersion = (pluginId) => {
|
|
48
|
-
const data = exports.useDocsData(pluginId);
|
|
49
|
-
return docsClientUtils_1.getLatestVersion(data);
|
|
51
|
+
const data = (0, exports.useDocsData)(pluginId);
|
|
52
|
+
return (0, docsClientUtils_1.getLatestVersion)(data);
|
|
50
53
|
};
|
|
51
54
|
exports.useLatestVersion = useLatestVersion;
|
|
52
55
|
// Note: return undefined on doc-unrelated pages,
|
|
53
56
|
// because there's no version currently considered as active
|
|
54
57
|
const useActiveVersion = (pluginId) => {
|
|
55
|
-
const data = exports.useDocsData(pluginId);
|
|
56
|
-
const { pathname } = router_1.useLocation();
|
|
57
|
-
return docsClientUtils_1.getActiveVersion(data, pathname);
|
|
58
|
+
const data = (0, exports.useDocsData)(pluginId);
|
|
59
|
+
const { pathname } = (0, router_1.useLocation)();
|
|
60
|
+
return (0, docsClientUtils_1.getActiveVersion)(data, pathname);
|
|
58
61
|
};
|
|
59
62
|
exports.useActiveVersion = useActiveVersion;
|
|
60
63
|
const useActiveDocContext = (pluginId) => {
|
|
61
|
-
const data = exports.useDocsData(pluginId);
|
|
62
|
-
const { pathname } = router_1.useLocation();
|
|
63
|
-
return docsClientUtils_1.getActiveDocContext(data, pathname);
|
|
64
|
+
const data = (0, exports.useDocsData)(pluginId);
|
|
65
|
+
const { pathname } = (0, router_1.useLocation)();
|
|
66
|
+
return (0, docsClientUtils_1.getActiveDocContext)(data, pathname);
|
|
64
67
|
};
|
|
65
68
|
exports.useActiveDocContext = useActiveDocContext;
|
|
66
69
|
// Useful to say "hey, you are not on the latest docs version, please switch"
|
|
67
70
|
const useDocVersionSuggestions = (pluginId) => {
|
|
68
|
-
const data = exports.useDocsData(pluginId);
|
|
69
|
-
const { pathname } = router_1.useLocation();
|
|
70
|
-
return docsClientUtils_1.getDocVersionSuggestions(data, pathname);
|
|
71
|
+
const data = (0, exports.useDocsData)(pluginId);
|
|
72
|
+
const { pathname } = (0, router_1.useLocation)();
|
|
73
|
+
return (0, docsClientUtils_1.getDocVersionSuggestions)(data, pathname);
|
|
71
74
|
};
|
|
72
75
|
exports.useDocVersionSuggestions = useDocVersionSuggestions;
|
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
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.translateLoadedContent = exports.getLoadedContentTranslationFiles = void 0;
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const utils_1 = require("./sidebars/utils");
|
|
12
|
+
const utils_2 = require("@docusaurus/utils");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
function getVersionFileName(versionName) {
|
|
15
15
|
if (versionName === constants_1.CURRENT_VERSION_NAME) {
|
|
@@ -32,7 +32,7 @@ function getNormalizedSidebarName({ versionName, sidebarName, }) {
|
|
|
32
32
|
return rest.join('/');
|
|
33
33
|
}
|
|
34
34
|
/*
|
|
35
|
-
// Do we need to translate doc
|
|
35
|
+
// Do we need to translate doc metadata?
|
|
36
36
|
// It seems translating frontmatter labels is good enough
|
|
37
37
|
function getDocTranslations(doc: DocMetadata): TranslationFileContent {
|
|
38
38
|
return {
|
|
@@ -74,31 +74,75 @@ 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
|
-
|
|
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) {
|
|
88
|
+
if (category.link.type === 'generated-index') {
|
|
89
|
+
if (category.link.title) {
|
|
90
|
+
entries.push([
|
|
91
|
+
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`,
|
|
92
|
+
{
|
|
93
|
+
message: category.link.title,
|
|
94
|
+
description: `The generated-index page title for category ${category.label} in sidebar ${sidebarName}`,
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
if (category.link.description) {
|
|
99
|
+
entries.push([
|
|
100
|
+
`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`,
|
|
101
|
+
{
|
|
102
|
+
message: category.link.description,
|
|
103
|
+
description: `The generated-index page description for category ${category.label} in sidebar ${sidebarName}`,
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return entries;
|
|
110
|
+
}));
|
|
111
|
+
const links = (0, utils_1.collectSidebarLinks)(sidebar);
|
|
112
|
+
const linksContent = (0, lodash_1.chain)(links)
|
|
87
113
|
.keyBy((link) => `sidebar.${sidebarName}.link.${link.label}`)
|
|
88
114
|
.mapValues((link) => ({
|
|
89
115
|
message: link.label,
|
|
90
116
|
description: `The label for link ${link.label} in sidebar ${sidebarName}, linking to ${link.href}`,
|
|
91
117
|
}))
|
|
92
118
|
.value();
|
|
93
|
-
return
|
|
119
|
+
return (0, utils_2.mergeTranslations)([categoryContent, linksContent]);
|
|
94
120
|
}
|
|
95
121
|
function translateSidebar({ sidebar, sidebarName, sidebarsTranslations, }) {
|
|
96
|
-
|
|
122
|
+
function transformSidebarCategoryLink(category) {
|
|
123
|
+
var _a, _b, _c, _d;
|
|
124
|
+
if (!category.link) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
if (category.link.type === 'generated-index') {
|
|
128
|
+
const title = (_b = (_a = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : category.link.title;
|
|
129
|
+
const description = (_d = (_c = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`]) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : category.link.description;
|
|
130
|
+
return {
|
|
131
|
+
...category.link,
|
|
132
|
+
title,
|
|
133
|
+
description,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return category.link;
|
|
137
|
+
}
|
|
138
|
+
return (0, utils_1.transformSidebarItems)(sidebar, (item) => {
|
|
97
139
|
var _a, _b, _c, _d;
|
|
98
140
|
if (item.type === 'category') {
|
|
141
|
+
const link = transformSidebarCategoryLink(item);
|
|
99
142
|
return {
|
|
100
143
|
...item,
|
|
101
144
|
label: (_b = (_a = sidebarsTranslations[`sidebar.${sidebarName}.category.${item.label}`]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : item.label,
|
|
145
|
+
...(link && { link }),
|
|
102
146
|
};
|
|
103
147
|
}
|
|
104
148
|
if (item.type === 'link') {
|
|
@@ -111,7 +155,7 @@ function translateSidebar({ sidebar, sidebarName, sidebarsTranslations, }) {
|
|
|
111
155
|
});
|
|
112
156
|
}
|
|
113
157
|
function getSidebarsTranslations(version) {
|
|
114
|
-
return
|
|
158
|
+
return (0, utils_2.mergeTranslations)(Object.entries(version.sidebars).map(([sidebarName, sidebar]) => {
|
|
115
159
|
const normalizedSidebarName = getNormalizedSidebarName({
|
|
116
160
|
sidebarName,
|
|
117
161
|
versionName: version.versionName,
|
|
@@ -120,16 +164,14 @@ function getSidebarsTranslations(version) {
|
|
|
120
164
|
}));
|
|
121
165
|
}
|
|
122
166
|
function translateSidebars(version, sidebarsTranslations) {
|
|
123
|
-
return lodash_1.mapValues(version.sidebars, (sidebar, sidebarName) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
sidebarName
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
});
|
|
167
|
+
return (0, lodash_1.mapValues)(version.sidebars, (sidebar, sidebarName) => translateSidebar({
|
|
168
|
+
sidebar,
|
|
169
|
+
sidebarName: getNormalizedSidebarName({
|
|
170
|
+
sidebarName,
|
|
171
|
+
versionName: version.versionName,
|
|
172
|
+
}),
|
|
173
|
+
sidebarsTranslations,
|
|
174
|
+
}));
|
|
133
175
|
}
|
|
134
176
|
function getVersionTranslationFiles(version) {
|
|
135
177
|
const versionTranslations = {
|
|
@@ -143,7 +185,7 @@ function getVersionTranslationFiles(version) {
|
|
|
143
185
|
return [
|
|
144
186
|
{
|
|
145
187
|
path: getVersionFileName(version.versionName),
|
|
146
|
-
content:
|
|
188
|
+
content: (0, utils_2.mergeTranslations)([
|
|
147
189
|
versionTranslations,
|
|
148
190
|
sidebarsTranslations,
|
|
149
191
|
// docsTranslations,
|
|
@@ -162,7 +204,7 @@ function translateVersion(version, translationFiles) {
|
|
|
162
204
|
};
|
|
163
205
|
}
|
|
164
206
|
function getVersionsTranslationFiles(versions) {
|
|
165
|
-
return
|
|
207
|
+
return versions.flatMap(getVersionTranslationFiles);
|
|
166
208
|
}
|
|
167
209
|
function translateVersions(versions, translationFiles) {
|
|
168
210
|
return versions.map((version) => translateVersion(version, translationFiles));
|
|
@@ -172,7 +214,7 @@ function getLoadedContentTranslationFiles(loadedContent) {
|
|
|
172
214
|
}
|
|
173
215
|
exports.getLoadedContentTranslationFiles = getLoadedContentTranslationFiles;
|
|
174
216
|
function translateLoadedContent(loadedContent, translationFiles) {
|
|
175
|
-
const translationFilesMap = lodash_1.keyBy(translationFiles, (f) => f.path);
|
|
217
|
+
const translationFilesMap = (0, lodash_1.keyBy)(translationFiles, (f) => f.path);
|
|
176
218
|
return {
|
|
177
219
|
loadedVersions: translateVersions(loadedContent.loadedVersions, translationFilesMap),
|
|
178
220
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { RemarkAndRehypePluginOptions } from '@docusaurus/mdx-loader';
|
|
8
|
-
import {
|
|
8
|
+
import type { Tag, FrontMatterTag, Slugger } from '@docusaurus/utils';
|
|
9
|
+
import type { BrokenMarkdownLink as IBrokenMarkdownLink, ContentPaths } from '@docusaurus/utils/lib/markdownLinks';
|
|
10
|
+
import type { SidebarItemsGeneratorOption, Sidebars } from './sidebars/types';
|
|
9
11
|
export declare type DocFile = {
|
|
10
12
|
contentPath: string;
|
|
11
13
|
filePath: string;
|
|
@@ -18,9 +20,12 @@ export declare type VersionMetadata = ContentPaths & {
|
|
|
18
20
|
versionName: VersionName;
|
|
19
21
|
versionLabel: string;
|
|
20
22
|
versionPath: string;
|
|
23
|
+
tagsPath: string;
|
|
21
24
|
versionEditUrl?: string | undefined;
|
|
22
25
|
versionEditUrlLocalized?: string | undefined;
|
|
23
|
-
versionBanner: VersionBanner;
|
|
26
|
+
versionBanner: VersionBanner | null;
|
|
27
|
+
versionBadge: boolean;
|
|
28
|
+
versionClassName: string;
|
|
24
29
|
isLast: boolean;
|
|
25
30
|
sidebarFilePath: string | false | undefined;
|
|
26
31
|
routePriority: number | undefined;
|
|
@@ -34,7 +39,6 @@ export declare type EditUrlFunction = (editUrlParams: {
|
|
|
34
39
|
}) => string | undefined;
|
|
35
40
|
export declare type MetadataOptions = {
|
|
36
41
|
routeBasePath: string;
|
|
37
|
-
homePageId?: string;
|
|
38
42
|
editUrl?: string | EditUrlFunction;
|
|
39
43
|
editCurrentVersion: boolean;
|
|
40
44
|
editLocalizedFiles: boolean;
|
|
@@ -46,80 +50,41 @@ export declare type PathOptions = {
|
|
|
46
50
|
path: string;
|
|
47
51
|
sidebarPath?: string | false | undefined;
|
|
48
52
|
};
|
|
49
|
-
export declare type VersionBanner = '
|
|
53
|
+
export declare type VersionBanner = 'unreleased' | 'unmaintained';
|
|
50
54
|
export declare type VersionOptions = {
|
|
51
55
|
path?: string;
|
|
52
56
|
label?: string;
|
|
53
|
-
banner?: VersionBanner;
|
|
57
|
+
banner?: 'none' | VersionBanner;
|
|
58
|
+
badge?: boolean;
|
|
59
|
+
className?: string;
|
|
54
60
|
};
|
|
55
61
|
export declare type VersionsOptions = {
|
|
56
62
|
lastVersion?: string;
|
|
57
63
|
versions: Record<string, VersionOptions>;
|
|
58
64
|
onlyIncludeVersions?: string[];
|
|
59
65
|
};
|
|
60
|
-
export declare type
|
|
66
|
+
export declare type SidebarOptions = {
|
|
67
|
+
sidebarCollapsible: boolean;
|
|
68
|
+
sidebarCollapsed: boolean;
|
|
69
|
+
};
|
|
70
|
+
export declare type NormalizeSidebarsParams = SidebarOptions & {
|
|
71
|
+
version: VersionMetadata;
|
|
72
|
+
categoryLabelSlugger: Slugger;
|
|
73
|
+
};
|
|
74
|
+
export declare type PluginOptions = MetadataOptions & PathOptions & VersionsOptions & RemarkAndRehypePluginOptions & SidebarOptions & {
|
|
61
75
|
id: string;
|
|
62
76
|
include: string[];
|
|
77
|
+
exclude: string[];
|
|
63
78
|
docLayoutComponent: string;
|
|
64
79
|
docItemComponent: string;
|
|
80
|
+
docTagDocListComponent: string;
|
|
81
|
+
docTagsListComponent: string;
|
|
82
|
+
docCategoryGeneratedIndexComponent: string;
|
|
65
83
|
admonitions: Record<string, unknown>;
|
|
66
84
|
disableVersioning: boolean;
|
|
67
85
|
includeCurrentVersion: boolean;
|
|
68
86
|
sidebarItemsGenerator: SidebarItemsGeneratorOption;
|
|
69
|
-
|
|
70
|
-
export declare type SidebarItemBase = {
|
|
71
|
-
customProps?: Record<string, unknown>;
|
|
72
|
-
};
|
|
73
|
-
export declare type SidebarItemDoc = SidebarItemBase & {
|
|
74
|
-
type: 'doc' | 'ref';
|
|
75
|
-
label?: string;
|
|
76
|
-
id: string;
|
|
77
|
-
};
|
|
78
|
-
export declare type SidebarItemLink = SidebarItemBase & {
|
|
79
|
-
type: 'link';
|
|
80
|
-
href: string;
|
|
81
|
-
label: string;
|
|
82
|
-
};
|
|
83
|
-
export declare type SidebarItemCategory = SidebarItemBase & {
|
|
84
|
-
type: 'category';
|
|
85
|
-
label: string;
|
|
86
|
-
items: SidebarItem[];
|
|
87
|
-
collapsed: boolean;
|
|
88
|
-
};
|
|
89
|
-
export declare type UnprocessedSidebarItemAutogenerated = {
|
|
90
|
-
type: 'autogenerated';
|
|
91
|
-
dirName: string;
|
|
92
|
-
};
|
|
93
|
-
export declare type UnprocessedSidebarItemCategory = SidebarItemBase & {
|
|
94
|
-
type: 'category';
|
|
95
|
-
label: string;
|
|
96
|
-
items: UnprocessedSidebarItem[];
|
|
97
|
-
collapsed: boolean;
|
|
98
|
-
};
|
|
99
|
-
export declare type UnprocessedSidebarItem = SidebarItemDoc | SidebarItemLink | UnprocessedSidebarItemCategory | UnprocessedSidebarItemAutogenerated;
|
|
100
|
-
export declare type UnprocessedSidebar = UnprocessedSidebarItem[];
|
|
101
|
-
export declare type UnprocessedSidebars = Record<string, UnprocessedSidebar>;
|
|
102
|
-
export declare type SidebarItem = SidebarItemDoc | SidebarItemLink | SidebarItemCategory;
|
|
103
|
-
export declare type Sidebar = SidebarItem[];
|
|
104
|
-
export declare type SidebarItemType = SidebarItem['type'];
|
|
105
|
-
export declare type Sidebars = Record<string, Sidebar>;
|
|
106
|
-
export declare type SidebarItemsGeneratorDoc = Pick<DocMetadataBase, 'id' | 'frontMatter' | 'source' | 'sourceDirName' | 'sidebarPosition'>;
|
|
107
|
-
export declare type SidebarItemsGeneratorVersion = Pick<VersionMetadata, 'versionName' | 'contentPath'>;
|
|
108
|
-
export declare type SidebarItemsGeneratorArgs = {
|
|
109
|
-
item: UnprocessedSidebarItemAutogenerated;
|
|
110
|
-
version: SidebarItemsGeneratorVersion;
|
|
111
|
-
docs: SidebarItemsGeneratorDoc[];
|
|
112
|
-
numberPrefixParser: NumberPrefixParser;
|
|
113
|
-
};
|
|
114
|
-
export declare type SidebarItemsGenerator = (generatorArgs: SidebarItemsGeneratorArgs) => Promise<SidebarItem[]>;
|
|
115
|
-
export declare type SidebarItemsGeneratorOptionArgs = {
|
|
116
|
-
defaultSidebarItemsGenerator: SidebarItemsGenerator;
|
|
117
|
-
} & SidebarItemsGeneratorArgs;
|
|
118
|
-
export declare type SidebarItemsGeneratorOption = (generatorArgs: SidebarItemsGeneratorOptionArgs) => Promise<SidebarItem[]>;
|
|
119
|
-
export declare type OrderMetadata = {
|
|
120
|
-
previous?: string;
|
|
121
|
-
next?: string;
|
|
122
|
-
sidebar?: string;
|
|
87
|
+
tagsBasePath: string;
|
|
123
88
|
};
|
|
124
89
|
export declare type LastUpdateData = {
|
|
125
90
|
lastUpdatedAt?: number;
|
|
@@ -129,6 +94,7 @@ export declare type LastUpdateData = {
|
|
|
129
94
|
export declare type DocFrontMatter = {
|
|
130
95
|
id?: string;
|
|
131
96
|
title?: string;
|
|
97
|
+
tags?: FrontMatterTag[];
|
|
132
98
|
hide_title?: boolean;
|
|
133
99
|
hide_table_of_contents?: boolean;
|
|
134
100
|
keywords?: string[];
|
|
@@ -137,15 +103,19 @@ export declare type DocFrontMatter = {
|
|
|
137
103
|
slug?: string;
|
|
138
104
|
sidebar_label?: string;
|
|
139
105
|
sidebar_position?: number;
|
|
106
|
+
sidebar_class_name?: string;
|
|
140
107
|
pagination_label?: string;
|
|
141
108
|
custom_edit_url?: string | null;
|
|
142
109
|
parse_number_prefixes?: boolean;
|
|
110
|
+
toc_min_heading_level?: number;
|
|
111
|
+
toc_max_heading_level?: number;
|
|
112
|
+
pagination_next?: string | null;
|
|
113
|
+
pagination_prev?: string | null;
|
|
143
114
|
};
|
|
144
115
|
export declare type DocMetadataBase = LastUpdateData & {
|
|
145
|
-
version: VersionName;
|
|
146
|
-
unversionedId: string;
|
|
147
116
|
id: string;
|
|
148
|
-
|
|
117
|
+
unversionedId: string;
|
|
118
|
+
version: VersionName;
|
|
149
119
|
title: string;
|
|
150
120
|
description: string;
|
|
151
121
|
source: string;
|
|
@@ -154,6 +124,7 @@ export declare type DocMetadataBase = LastUpdateData & {
|
|
|
154
124
|
permalink: string;
|
|
155
125
|
sidebarPosition?: number;
|
|
156
126
|
editUrl?: string | null;
|
|
127
|
+
tags: Tag[];
|
|
157
128
|
frontMatter: DocFrontMatter & Record<string, unknown>;
|
|
158
129
|
};
|
|
159
130
|
export declare type DocNavLink = {
|
|
@@ -165,15 +136,32 @@ export declare type DocMetadata = DocMetadataBase & {
|
|
|
165
136
|
previous?: DocNavLink;
|
|
166
137
|
next?: DocNavLink;
|
|
167
138
|
};
|
|
139
|
+
export declare type CategoryGeneratedIndexMetadata = {
|
|
140
|
+
title: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
slug: string;
|
|
143
|
+
permalink: string;
|
|
144
|
+
sidebar: string;
|
|
145
|
+
previous?: DocNavLink;
|
|
146
|
+
next?: DocNavLink;
|
|
147
|
+
};
|
|
168
148
|
export declare type SourceToPermalink = {
|
|
169
149
|
[source: string]: string;
|
|
170
150
|
};
|
|
151
|
+
export declare type VersionTag = {
|
|
152
|
+
name: string;
|
|
153
|
+
docIds: string[];
|
|
154
|
+
permalink: string;
|
|
155
|
+
};
|
|
156
|
+
export declare type VersionTags = {
|
|
157
|
+
[key: string]: VersionTag;
|
|
158
|
+
};
|
|
171
159
|
export declare type LoadedVersion = VersionMetadata & {
|
|
172
160
|
versionPath: string;
|
|
173
161
|
mainDocId: string;
|
|
174
162
|
docs: DocMetadata[];
|
|
175
163
|
sidebars: Sidebars;
|
|
176
|
-
|
|
164
|
+
categoryGeneratedIndices: CategoryGeneratedIndexMetadata[];
|
|
177
165
|
};
|
|
178
166
|
export declare type LoadedContent = {
|
|
179
167
|
loadedVersions: LoadedVersion[];
|
package/lib/versions.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
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 { PluginOptions, VersionMetadata } from './types';
|
|
8
|
-
import { LoadContext } from '@docusaurus/types';
|
|
7
|
+
import type { PluginOptions, VersionMetadata } from './types';
|
|
8
|
+
import type { LoadContext } from '@docusaurus/types';
|
|
9
9
|
export declare function getVersionedDocsDirPath(siteDir: string, pluginId: string): string;
|
|
10
10
|
export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: string): string;
|
|
11
11
|
export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
|
|
12
12
|
export declare function readVersionsMetadata({ context, options, }: {
|
|
13
13
|
context: Pick<LoadContext, 'siteDir' | 'baseUrl' | 'i18n'>;
|
|
14
|
-
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
14
|
+
options: Pick<PluginOptions, 'id' | 'path' | 'sidebarPath' | 'routeBasePath' | 'tagsBasePath' | 'includeCurrentVersion' | 'disableVersioning' | 'lastVersion' | 'versions' | 'onlyIncludeVersions' | 'editUrl' | 'editCurrentVersion'>;
|
|
15
15
|
}): VersionMetadata[];
|
|
16
16
|
export declare function getDocsDirPaths(versionMetadata: Pick<VersionMetadata, 'contentPath' | 'contentPathLocalized'>): [string, string];
|