@docusaurus/plugin-content-docs 3.2.1 → 3.3.1

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.
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import { type SidebarsUtils } from './sidebars/utils';
8
9
  import type { CategoryGeneratedIndexMetadata, DocMetadataBase } from '@docusaurus/plugin-content-docs';
9
10
  export declare function getCategoryGeneratedIndexMetadataList({ docs, sidebarsUtils, }: {
package/lib/cli.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
9
  import type { LoadContext } from '@docusaurus/types';
9
10
  export declare function cliDocsVersionCommand(version: unknown, { id: pluginId, path: docsPath, sidebarPath }: PluginOptions, { siteDir, i18n }: LoadContext): Promise<void>;
package/lib/docs.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { MetadataOptions, PluginOptions, CategoryIndexMatcher, DocMetadataBase, VersionMetadata, LoadedVersion } from '@docusaurus/plugin-content-docs';
8
9
  import type { LoadContext } from '@docusaurus/types';
9
10
  import type { SidebarsUtils } from './sidebars/utils';
@@ -1,3 +1,4 @@
1
+ /// <reference path="../src/plugin-content-docs.d.ts" />
1
2
  import type { DocFrontMatter } from '@docusaurus/plugin-content-docs';
2
3
  export declare const DocFrontMatterSchema: import("joi").ObjectSchema<DocFrontMatter>;
3
4
  export declare function validateDocFrontMatter(frontMatter: {
package/lib/index.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { PluginOptions, LoadedContent } from '@docusaurus/plugin-content-docs';
8
9
  import type { LoadContext, Plugin } from '@docusaurus/types';
9
10
  export default function pluginContentDocs(context: LoadContext, options: PluginOptions): Promise<Plugin<LoadedContent>>;
package/lib/index.js CHANGED
@@ -30,6 +30,9 @@ async function pluginContentDocs(context, options) {
30
30
  const pluginId = options.id;
31
31
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
32
32
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
33
+ // TODO Docusaurus v4 breaking change
34
+ // module aliasing should be automatic
35
+ // we should never find local absolute FS paths in the codegen registry
33
36
  const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
34
37
  // TODO env should be injected into all plugins
35
38
  const env = process.env.NODE_ENV;
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
8
9
  export declare const DefaultNumberPrefixParser: NumberPrefixParser;
9
10
  export declare const DisabledNumberPrefixParser: NumberPrefixParser;
package/lib/options.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { OptionValidationContext } from '@docusaurus/types';
8
9
  import type { PluginOptions, Options } from '@docusaurus/plugin-content-docs';
9
10
  export declare const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'>;
package/lib/options.js CHANGED
@@ -14,10 +14,10 @@ const utils_1 = require("@docusaurus/utils");
14
14
  const generator_1 = require("./sidebars/generator");
15
15
  const numberPrefix_1 = require("./numberPrefix");
16
16
  exports.DEFAULT_OPTIONS = {
17
- path: 'docs',
18
- routeBasePath: 'docs',
19
- tagsBasePath: 'tags',
20
- include: ['**/*.{md,mdx}'],
17
+ path: 'docs', // Path to data on filesystem, relative to site dir.
18
+ routeBasePath: 'docs', // URL Route.
19
+ tagsBasePath: 'tags', // URL Tags Route.
20
+ include: ['**/*.{md,mdx}'], // Extensions to include.
21
21
  exclude: utils_1.GlobExcludeDefault,
22
22
  sidebarItemsGenerator: generator_1.DefaultSidebarItemsGenerator,
23
23
  numberPrefixParser: numberPrefix_1.DefaultNumberPrefixParser,
package/lib/props.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { VersionTag, VersionTags } from './types';
8
9
  import type { SidebarItemDoc } from './sidebars/types';
9
10
  import type { PropSidebars, PropVersionMetadata, PropTagDocList, PropTagsListPage, PropSidebarItemLink, DocMetadata, LoadedVersion } from '@docusaurus/plugin-content-docs';
package/lib/routes.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
8
9
  import type { FullVersion } from './types';
9
10
  import type { PluginOptions } from '@docusaurus/plugin-content-docs';
package/lib/routes.js CHANGED
@@ -19,22 +19,20 @@ function createDocRouteMetadata(docMeta) {
19
19
  lastUpdatedAt: docMeta.lastUpdatedAt,
20
20
  };
21
21
  }
22
- async function buildVersionCategoryGeneratedIndexRoutes({ version, actions, options, aliasedSource, }) {
23
- const slugs = (0, utils_1.createSlugger)();
22
+ async function buildVersionCategoryGeneratedIndexRoutes({ version, options, }) {
24
23
  async function buildCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
25
- const { sidebar, ...prop } = categoryGeneratedIndex;
26
- const propFileName = slugs.slug(`${version.path}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`);
27
- const propData = await actions.createData(`${(0, utils_1.docuHash)(`category/${propFileName}`)}.json`, JSON.stringify(prop, null, 2));
28
24
  return {
29
25
  path: categoryGeneratedIndex.permalink,
30
26
  component: options.docCategoryGeneratedIndexComponent,
31
27
  exact: true,
32
- modules: {
33
- categoryGeneratedIndex: aliasedSource(propData),
28
+ props: {
29
+ categoryGeneratedIndex,
34
30
  },
35
31
  // Same as doc, this sidebar route attribute permits to associate this
36
32
  // subpage to the given sidebar
37
- ...(sidebar && { sidebar }),
33
+ ...(categoryGeneratedIndex.sidebar && {
34
+ sidebar: categoryGeneratedIndex.sidebar,
35
+ }),
38
36
  };
39
37
  }
40
38
  return Promise.all(version.categoryGeneratedIndices.map(buildCategoryGeneratedIndexRoute));
@@ -44,7 +42,7 @@ async function buildVersionDocRoutes({ version, actions, options, }) {
44
42
  await actions.createData(
45
43
  // Note that this created data path must be in sync with
46
44
  // metadataPath provided to mdx-loader.
47
- `${(0, utils_1.docuHash)(doc.source)}.json`, JSON.stringify(doc, null, 2));
45
+ `${(0, utils_1.docuHash)(doc.source)}.json`, doc);
48
46
  const docRoute = {
49
47
  path: doc.permalink,
50
48
  component: options.docItemComponent,
@@ -77,37 +75,33 @@ async function buildVersionSidebarRoute(param) {
77
75
  };
78
76
  }
79
77
  async function buildVersionTagsRoutes(param) {
80
- const { version, options, actions, aliasedSource } = param;
78
+ const { version, options } = param;
81
79
  const versionTags = (0, tags_1.getVersionTags)(version.docs);
82
80
  async function buildTagsListRoute() {
83
81
  // Don't create a tags list page if there's no tag
84
82
  if (Object.keys(versionTags).length === 0) {
85
83
  return null;
86
84
  }
87
- const tagsProp = (0, props_1.toTagsListTagsProp)(versionTags);
88
- const tagsPropPath = await actions.createData(`${(0, utils_1.docuHash)(`tags-list-${version.versionName}-prop`)}.json`, JSON.stringify(tagsProp, null, 2));
89
85
  return {
90
86
  path: version.tagsPath,
91
87
  exact: true,
92
88
  component: options.docTagsListComponent,
93
- modules: {
94
- tags: aliasedSource(tagsPropPath),
89
+ props: {
90
+ tags: (0, props_1.toTagsListTagsProp)(versionTags),
95
91
  },
96
92
  };
97
93
  }
98
94
  async function buildTagDocListRoute(tag) {
99
- const tagProps = (0, props_1.toTagDocListProp)({
100
- allTagsPath: version.tagsPath,
101
- tag,
102
- docs: version.docs,
103
- });
104
- const tagPropPath = await actions.createData(`${(0, utils_1.docuHash)(`tag-${tag.permalink}`)}.json`, JSON.stringify(tagProps, null, 2));
105
95
  return {
106
96
  path: tag.permalink,
107
97
  component: options.docTagDocListComponent,
108
98
  exact: true,
109
- modules: {
110
- tag: aliasedSource(tagPropPath),
99
+ props: {
100
+ tag: (0, props_1.toTagDocListProp)({
101
+ allTagsPath: version.tagsPath,
102
+ tag,
103
+ docs: version.docs,
104
+ }),
111
105
  },
112
106
  };
113
107
  }
@@ -118,7 +112,7 @@ async function buildVersionTagsRoutes(param) {
118
112
  return lodash_1.default.compact([tagsListRoute, ...allTagsDocListRoutes]);
119
113
  }
120
114
  async function buildVersionRoutes(param) {
121
- const { version, actions, options, aliasedSource } = param;
115
+ const { version, options } = param;
122
116
  async function buildVersionSubRoutes() {
123
117
  const [sidebarRoute, tagsRoutes] = await Promise.all([
124
118
  buildVersionSidebarRoute(param),
@@ -127,16 +121,15 @@ async function buildVersionRoutes(param) {
127
121
  return [sidebarRoute, ...tagsRoutes];
128
122
  }
129
123
  async function doBuildVersionRoutes() {
130
- const versionProp = (0, props_1.toVersionMetadataProp)(options.id, version);
131
- const versionPropPath = await actions.createData(`${(0, utils_1.docuHash)(`version-${version.versionName}-metadata-prop`)}.json`, JSON.stringify(versionProp, null, 2));
132
- const subRoutes = await buildVersionSubRoutes();
133
124
  return {
134
125
  path: version.path,
135
126
  exact: false,
136
127
  component: options.docVersionRootComponent,
137
- routes: subRoutes,
138
- modules: {
139
- version: aliasedSource(versionPropPath),
128
+ routes: await buildVersionSubRoutes(),
129
+ props: {
130
+ // TODO Docusaurus v4 breaking change?
131
+ // expose version metadata as route context instead of props
132
+ version: (0, props_1.toVersionMetadataProp)(options.id, version),
140
133
  },
141
134
  priority: version.routePriority,
142
135
  };
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
9
  import type { SidebarsConfig, Sidebars, SidebarProcessorParams } from './types';
9
10
  export declare const DefaultSidebars: SidebarsConfig;
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { Optional, Required } from 'utility-types';
8
9
  import type { NumberPrefixParser, SidebarOptions, CategoryIndexMatcher, DocMetadataBase, VersionMetadata } from '@docusaurus/plugin-content-docs';
9
10
  import type { Slugger } from '@docusaurus/utils';
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { Sidebars, Sidebar, SidebarItem, SidebarItemCategory, SidebarItemLink, SidebarItemDoc, SidebarCategoriesShorthand, SidebarItemConfig, SidebarItemCategoryWithGeneratedIndex, SidebarNavigationItem } from './types';
8
9
  import type { DocMetadataBase, PropNavigationLink, VersionMetadata } from '@docusaurus/plugin-content-docs';
9
10
  export declare function isCategoriesShorthand(item: SidebarItemConfig): item is SidebarCategoriesShorthand;
@@ -61,7 +62,9 @@ export type SidebarsUtils = {
61
62
  }) => void;
62
63
  };
63
64
  export declare function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils;
64
- export declare function toDocNavigationLink(doc: DocMetadataBase): PropNavigationLink;
65
+ export declare function toDocNavigationLink(doc: DocMetadataBase, options?: {
66
+ sidebarItemLabel?: string | undefined;
67
+ }): PropNavigationLink;
65
68
  export declare function toNavigationLink(navigationItem: SidebarNavigationItem | undefined, docsById: {
66
69
  [docId: string]: DocMetadataBase;
67
70
  }): PropNavigationLink | undefined;
@@ -294,9 +294,12 @@ Available document ids are:
294
294
  };
295
295
  }
296
296
  exports.createSidebarsUtils = createSidebarsUtils;
297
- function toDocNavigationLink(doc) {
297
+ function toDocNavigationLink(doc, options) {
298
298
  const { title, permalink, frontMatter: { pagination_label: paginationLabel, sidebar_label: sidebarLabel, }, } = doc;
299
- return { title: paginationLabel ?? sidebarLabel ?? title, permalink };
299
+ return {
300
+ title: paginationLabel ?? sidebarLabel ?? options?.sidebarItemLabel ?? title,
301
+ permalink,
302
+ };
300
303
  }
301
304
  exports.toDocNavigationLink = toDocNavigationLink;
302
305
  function toNavigationLink(navigationItem, docsById) {
@@ -318,6 +321,8 @@ function toNavigationLink(navigationItem, docsById) {
318
321
  permalink: navigationItem.link.permalink,
319
322
  };
320
323
  }
321
- return toDocNavigationLink(getDocById(navigationItem.id));
324
+ return toDocNavigationLink(getDocById(navigationItem.id), {
325
+ sidebarItemLabel: navigationItem?.label,
326
+ });
322
327
  }
323
328
  exports.toNavigationLink = toNavigationLink;
package/lib/slug.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { NumberPrefixParser, DocMetadataBase } from '@docusaurus/plugin-content-docs';
8
9
  export default function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumberPrefixes, numberPrefixParser, }: {
9
10
  baseID: string;
package/lib/tags.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { VersionTags } from './types';
8
9
  import type { DocMetadata } from '@docusaurus/plugin-content-docs';
9
10
  export declare function getVersionTags(docs: DocMetadata[]): VersionTags;
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { LoadedContent } from '@docusaurus/plugin-content-docs';
8
9
  import type { TranslationFile } from '@docusaurus/types';
9
10
  export declare function getLoadedContentTranslationFiles(loadedContent: LoadedContent): TranslationFile[];
package/lib/types.d.ts CHANGED
@@ -4,6 +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
+ /// <reference path="../src/plugin-content-docs.d.ts" />
7
8
  import type { BrokenMarkdownLink, Tag } from '@docusaurus/utils';
8
9
  import type { VersionMetadata, LoadedVersion, CategoryGeneratedIndexMetadata } from '@docusaurus/plugin-content-docs';
9
10
  import type { SidebarsUtils } from './sidebars/utils';
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { PluginOptions, VersionMetadata } from '@docusaurus/plugin-content-docs';
8
9
  import type { VersionContext } from './index';
9
10
  /** `[siteDir]/community_versioned_docs/version-1.0.0` */
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { FullVersion } from '../types';
8
9
  import type { LoadContext } from '@docusaurus/types';
9
10
  import type { LoadedVersion, PluginOptions, VersionBanner, VersionMetadata } from '@docusaurus/plugin-content-docs';
@@ -4,6 +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
+ /// <reference path="../../src/plugin-content-docs.d.ts" />
7
8
  import type { VersionsOptions } from '@docusaurus/plugin-content-docs';
8
9
  export declare function validateVersionName(name: unknown): asserts name is string;
9
10
  export declare function validateVersionNames(names: unknown): asserts names is string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@docusaurus/core": "3.2.1",
39
- "@docusaurus/logger": "3.2.1",
40
- "@docusaurus/mdx-loader": "3.2.1",
41
- "@docusaurus/module-type-aliases": "3.2.1",
42
- "@docusaurus/types": "3.2.1",
43
- "@docusaurus/utils": "3.2.1",
44
- "@docusaurus/utils-common": "3.2.1",
45
- "@docusaurus/utils-validation": "3.2.1",
38
+ "@docusaurus/core": "3.3.1",
39
+ "@docusaurus/logger": "3.3.0",
40
+ "@docusaurus/mdx-loader": "3.3.0",
41
+ "@docusaurus/module-type-aliases": "3.3.1",
42
+ "@docusaurus/types": "3.3.0",
43
+ "@docusaurus/utils": "3.3.0",
44
+ "@docusaurus/utils-common": "3.3.0",
45
+ "@docusaurus/utils-validation": "3.3.0",
46
46
  "@types/react-router-config": "^5.0.7",
47
47
  "combine-promises": "^1.1.0",
48
48
  "fs-extra": "^11.1.1",
@@ -66,5 +66,5 @@
66
66
  "engines": {
67
67
  "node": ">=18.0"
68
68
  },
69
- "gitHead": "f268e15264e208e6faf26117258162e988b53773"
69
+ "gitHead": "f3524cf332e803ff82783ee9c1c86c4342fc1f71"
70
70
  }
package/src/index.ts CHANGED
@@ -73,6 +73,9 @@ export default async function pluginContentDocs(
73
73
  'docusaurus-plugin-content-docs',
74
74
  );
75
75
  const dataDir = path.join(pluginDataDirRoot, pluginId);
76
+ // TODO Docusaurus v4 breaking change
77
+ // module aliasing should be automatic
78
+ // we should never find local absolute FS paths in the codegen registry
76
79
  const aliasedSource = (source: string) =>
77
80
  `~docs/${posixPath(path.relative(pluginDataDirRoot, source))}`;
78
81
 
package/src/routes.ts CHANGED
@@ -9,7 +9,6 @@ import _ from 'lodash';
9
9
  import logger from '@docusaurus/logger';
10
10
  import {
11
11
  docuHash,
12
- createSlugger,
13
12
  normalizeUrl,
14
13
  aliasedSitePathToRelativePath,
15
14
  } from '@docusaurus/utils';
@@ -29,7 +28,6 @@ import type {
29
28
  CategoryGeneratedIndexMetadata,
30
29
  DocMetadata,
31
30
  PluginOptions,
32
- PropTagsListPage,
33
31
  } from '@docusaurus/plugin-content-docs';
34
32
 
35
33
  function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
@@ -41,36 +39,23 @@ function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
41
39
 
42
40
  async function buildVersionCategoryGeneratedIndexRoutes({
43
41
  version,
44
- actions,
45
42
  options,
46
- aliasedSource,
47
43
  }: BuildVersionRoutesParam): Promise<RouteConfig[]> {
48
- const slugs = createSlugger();
49
-
50
44
  async function buildCategoryGeneratedIndexRoute(
51
45
  categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
52
46
  ): Promise<RouteConfig> {
53
- const {sidebar, ...prop} = categoryGeneratedIndex;
54
-
55
- const propFileName = slugs.slug(
56
- `${version.path}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`,
57
- );
58
-
59
- const propData = await actions.createData(
60
- `${docuHash(`category/${propFileName}`)}.json`,
61
- JSON.stringify(prop, null, 2),
62
- );
63
-
64
47
  return {
65
48
  path: categoryGeneratedIndex.permalink,
66
49
  component: options.docCategoryGeneratedIndexComponent,
67
50
  exact: true,
68
- modules: {
69
- categoryGeneratedIndex: aliasedSource(propData),
51
+ props: {
52
+ categoryGeneratedIndex,
70
53
  },
71
54
  // Same as doc, this sidebar route attribute permits to associate this
72
55
  // subpage to the given sidebar
73
- ...(sidebar && {sidebar}),
56
+ ...(categoryGeneratedIndex.sidebar && {
57
+ sidebar: categoryGeneratedIndex.sidebar,
58
+ }),
74
59
  };
75
60
  }
76
61
 
@@ -90,7 +75,7 @@ async function buildVersionDocRoutes({
90
75
  // Note that this created data path must be in sync with
91
76
  // metadataPath provided to mdx-loader.
92
77
  `${docuHash(doc.source)}.json`,
93
- JSON.stringify(doc, null, 2),
78
+ doc,
94
79
  );
95
80
 
96
81
  const docRoute: RouteConfig = {
@@ -131,7 +116,7 @@ async function buildVersionSidebarRoute(param: BuildVersionRoutesParam) {
131
116
  async function buildVersionTagsRoutes(
132
117
  param: BuildVersionRoutesParam,
133
118
  ): Promise<RouteConfig[]> {
134
- const {version, options, actions, aliasedSource} = param;
119
+ const {version, options} = param;
135
120
  const versionTags = getVersionTags(version.docs);
136
121
 
137
122
  async function buildTagsListRoute(): Promise<RouteConfig | null> {
@@ -139,37 +124,27 @@ async function buildVersionTagsRoutes(
139
124
  if (Object.keys(versionTags).length === 0) {
140
125
  return null;
141
126
  }
142
- const tagsProp: PropTagsListPage['tags'] = toTagsListTagsProp(versionTags);
143
- const tagsPropPath = await actions.createData(
144
- `${docuHash(`tags-list-${version.versionName}-prop`)}.json`,
145
- JSON.stringify(tagsProp, null, 2),
146
- );
147
127
  return {
148
128
  path: version.tagsPath,
149
129
  exact: true,
150
130
  component: options.docTagsListComponent,
151
- modules: {
152
- tags: aliasedSource(tagsPropPath),
131
+ props: {
132
+ tags: toTagsListTagsProp(versionTags),
153
133
  },
154
134
  };
155
135
  }
156
136
 
157
137
  async function buildTagDocListRoute(tag: VersionTag): Promise<RouteConfig> {
158
- const tagProps = toTagDocListProp({
159
- allTagsPath: version.tagsPath,
160
- tag,
161
- docs: version.docs,
162
- });
163
- const tagPropPath = await actions.createData(
164
- `${docuHash(`tag-${tag.permalink}`)}.json`,
165
- JSON.stringify(tagProps, null, 2),
166
- );
167
138
  return {
168
139
  path: tag.permalink,
169
140
  component: options.docTagDocListComponent,
170
141
  exact: true,
171
- modules: {
172
- tag: aliasedSource(tagPropPath),
142
+ props: {
143
+ tag: toTagDocListProp({
144
+ allTagsPath: version.tagsPath,
145
+ tag,
146
+ docs: version.docs,
147
+ }),
173
148
  },
174
149
  };
175
150
  }
@@ -189,7 +164,7 @@ type BuildVersionRoutesParam = Omit<BuildAllRoutesParam, 'versions'> & {
189
164
  async function buildVersionRoutes(
190
165
  param: BuildVersionRoutesParam,
191
166
  ): Promise<RouteConfig> {
192
- const {version, actions, options, aliasedSource} = param;
167
+ const {version, options} = param;
193
168
 
194
169
  async function buildVersionSubRoutes() {
195
170
  const [sidebarRoute, tagsRoutes] = await Promise.all([
@@ -201,19 +176,15 @@ async function buildVersionRoutes(
201
176
  }
202
177
 
203
178
  async function doBuildVersionRoutes(): Promise<RouteConfig> {
204
- const versionProp = toVersionMetadataProp(options.id, version);
205
- const versionPropPath = await actions.createData(
206
- `${docuHash(`version-${version.versionName}-metadata-prop`)}.json`,
207
- JSON.stringify(versionProp, null, 2),
208
- );
209
- const subRoutes = await buildVersionSubRoutes();
210
179
  return {
211
180
  path: version.path,
212
181
  exact: false,
213
182
  component: options.docVersionRootComponent,
214
- routes: subRoutes,
215
- modules: {
216
- version: aliasedSource(versionPropPath),
183
+ routes: await buildVersionSubRoutes(),
184
+ props: {
185
+ // TODO Docusaurus v4 breaking change?
186
+ // expose version metadata as route context instead of props
187
+ version: toVersionMetadataProp(options.id, version),
217
188
  },
218
189
  priority: version.routePriority,
219
190
  };
@@ -478,7 +478,10 @@ Available document ids are:
478
478
  };
479
479
  }
480
480
 
481
- export function toDocNavigationLink(doc: DocMetadataBase): PropNavigationLink {
481
+ export function toDocNavigationLink(
482
+ doc: DocMetadataBase,
483
+ options?: {sidebarItemLabel?: string | undefined},
484
+ ): PropNavigationLink {
482
485
  const {
483
486
  title,
484
487
  permalink,
@@ -487,7 +490,11 @@ export function toDocNavigationLink(doc: DocMetadataBase): PropNavigationLink {
487
490
  sidebar_label: sidebarLabel,
488
491
  },
489
492
  } = doc;
490
- return {title: paginationLabel ?? sidebarLabel ?? title, permalink};
493
+ return {
494
+ title:
495
+ paginationLabel ?? sidebarLabel ?? options?.sidebarItemLabel ?? title,
496
+ permalink,
497
+ };
491
498
  }
492
499
 
493
500
  export function toNavigationLink(
@@ -516,5 +523,7 @@ export function toNavigationLink(
516
523
  permalink: navigationItem.link.permalink,
517
524
  };
518
525
  }
519
- return toDocNavigationLink(getDocById(navigationItem.id));
526
+ return toDocNavigationLink(getDocById(navigationItem.id), {
527
+ sidebarItemLabel: navigationItem?.label,
528
+ });
520
529
  }