@docusaurus/plugin-content-docs 2.0.0-beta.13 → 2.0.0-beta.15

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.
Files changed (197) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +2 -2
  2. package/lib/categoryGeneratedIndex.js +2 -0
  3. package/lib/cli.d.ts +1 -1
  4. package/lib/cli.js +2 -1
  5. package/lib/client/docsClientUtils.d.ts +3 -22
  6. package/lib/client/docsClientUtils.js +5 -1
  7. package/lib/{theme/hooks/useDocs.d.ts → client/globalDataHooks.d.ts} +1 -2
  8. package/lib/{theme/hooks/useDocs.js → client/globalDataHooks.js} +2 -1
  9. package/{src/__tests__/__fixtures__/simple-site/docusaurus.config.js → lib/client/index.d.ts} +1 -8
  10. package/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/client/index.js} +4 -8
  11. package/lib/docFrontMatter.js +1 -0
  12. package/lib/docs.d.ts +19 -6
  13. package/lib/docs.js +43 -22
  14. package/lib/globalData.d.ts +5 -1
  15. package/lib/globalData.js +34 -2
  16. package/lib/index.d.ts +3 -2
  17. package/lib/index.js +4 -10
  18. package/lib/lastUpdate.js +6 -5
  19. package/lib/markdown/index.d.ts +1 -1
  20. package/lib/markdown/linkify.d.ts +1 -1
  21. package/lib/numberPrefix.d.ts +1 -1
  22. package/lib/options.d.ts +1 -1
  23. package/lib/options.js +2 -2
  24. package/lib/routes.d.ts +4 -3
  25. package/lib/routes.js +8 -5
  26. package/lib/sidebars/generator.js +15 -17
  27. package/lib/sidebars/index.d.ts +3 -2
  28. package/lib/sidebars/processor.d.ts +3 -2
  29. package/lib/sidebars/processor.js +2 -0
  30. package/lib/sidebars/types.d.ts +8 -3
  31. package/lib/sidebars/utils.d.ts +12 -4
  32. package/lib/sidebars/utils.js +48 -3
  33. package/lib/sidebars/validation.d.ts +1 -1
  34. package/lib/sidebars/validation.js +4 -0
  35. package/lib/slug.d.ts +5 -4
  36. package/lib/slug.js +8 -7
  37. package/lib/translations.js +1 -1
  38. package/lib/types.d.ts +7 -78
  39. package/lib/versions.d.ts +3 -2
  40. package/lib/versions.js +27 -32
  41. package/package.json +14 -12
  42. package/src/categoryGeneratedIndex.ts +5 -3
  43. package/src/cli.ts +6 -2
  44. package/src/client/docsClientUtils.ts +22 -35
  45. package/src/{theme/hooks/useDocs.ts → client/globalDataHooks.ts} +6 -2
  46. package/src/{__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → client/index.ts} +1 -9
  47. package/src/docFrontMatter.ts +2 -1
  48. package/src/docs.ts +77 -42
  49. package/src/globalData.ts +49 -3
  50. package/src/index.ts +11 -21
  51. package/src/lastUpdate.ts +6 -5
  52. package/src/markdown/index.ts +1 -1
  53. package/src/markdown/linkify.ts +1 -1
  54. package/src/numberPrefix.ts +1 -1
  55. package/src/options.ts +3 -7
  56. package/src/plugin-content-docs.d.ts +128 -18
  57. package/src/routes.ts +21 -11
  58. package/src/sidebars/generator.ts +28 -31
  59. package/src/sidebars/index.ts +3 -2
  60. package/src/sidebars/normalization.ts +2 -1
  61. package/src/sidebars/processor.ts +8 -7
  62. package/src/sidebars/types.ts +9 -5
  63. package/src/sidebars/utils.ts +76 -8
  64. package/src/sidebars/validation.ts +6 -1
  65. package/src/slug.ts +15 -11
  66. package/src/translations.ts +2 -2
  67. package/src/types.ts +12 -98
  68. package/src/versions.ts +51 -47
  69. package/lib/.tsbuildinfo +0 -1
  70. package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
  71. package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
  72. package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
  73. package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
  74. package/src/__tests__/__fixtures__/simple-site/docs/_partials/somePartial.md +0 -3
  75. package/src/__tests__/__fixtures__/simple-site/docs/_partials/subfolder/somePartial.md +0 -3
  76. package/src/__tests__/__fixtures__/simple-site/docs/_somePartial.md +0 -3
  77. package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
  78. package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -75
  79. package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
  80. package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -55
  81. package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
  82. package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
  83. package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -7
  84. package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -7
  85. package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -7
  86. package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -7
  87. package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
  88. package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
  89. package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
  90. package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
  91. package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -37
  92. package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
  93. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
  94. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
  95. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
  96. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
  97. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
  98. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
  99. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
  100. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
  101. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
  102. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
  103. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
  104. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
  105. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
  106. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
  107. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
  108. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
  109. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
  110. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js +0 -14
  111. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
  112. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -8
  113. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
  114. package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
  115. package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
  116. package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
  117. package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
  118. package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
  119. package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
  120. package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -10
  121. package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -4
  122. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
  123. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
  124. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
  125. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
  126. package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
  127. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -4
  128. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
  129. package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -4
  130. package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
  131. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
  132. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
  133. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -4
  134. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/somePartial.md +0 -3
  135. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_partials/subfolder/somePartial.md +0 -3
  136. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/_somePartial.md +0 -3
  137. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
  138. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -4
  139. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
  140. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
  141. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
  142. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
  143. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
  144. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
  145. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
  146. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
  147. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  148. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
  149. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
  150. package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
  151. package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -65
  152. package/src/__tests__/__snapshots__/docs.test.ts.snap +0 -140
  153. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -2550
  154. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -514
  155. package/src/__tests__/cli.test.ts +0 -337
  156. package/src/__tests__/docFrontMatter.test.ts +0 -359
  157. package/src/__tests__/docs.test.ts +0 -1039
  158. package/src/__tests__/index.test.ts +0 -1910
  159. package/src/__tests__/lastUpdate.test.ts +0 -69
  160. package/src/__tests__/numberPrefix.test.ts +0 -199
  161. package/src/__tests__/options.test.ts +0 -276
  162. package/src/__tests__/props.test.ts +0 -62
  163. package/src/__tests__/slug.test.ts +0 -216
  164. package/src/__tests__/translations.test.ts +0 -164
  165. package/src/__tests__/versions.test.ts +0 -744
  166. package/src/client/__tests__/docsClientUtils.test.ts +0 -371
  167. package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
  168. package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
  169. package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
  170. package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
  171. package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
  172. package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
  173. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
  174. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
  175. package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
  176. package/src/markdown/__tests__/linkify.test.ts +0 -190
  177. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
  178. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
  179. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
  180. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
  181. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
  182. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
  183. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
  184. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
  185. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
  186. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
  187. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
  188. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
  189. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
  190. package/src/sidebars/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
  191. package/src/sidebars/__tests__/__snapshots__/index.test.ts.snap +0 -248
  192. package/src/sidebars/__tests__/generator.test.ts +0 -461
  193. package/src/sidebars/__tests__/index.test.ts +0 -204
  194. package/src/sidebars/__tests__/processor.test.ts +0 -237
  195. package/src/sidebars/__tests__/utils.test.ts +0 -695
  196. package/src/sidebars/__tests__/validation.test.ts +0 -105
  197. package/tsconfig.json +0 -9
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { CategoryGeneratedIndexMetadata, DocMetadataBase } from './types';
8
- import { SidebarsUtils } from './sidebars/utils';
7
+ import type { CategoryGeneratedIndexMetadata, DocMetadataBase } from './types';
8
+ import { type SidebarsUtils } from './sidebars/utils';
9
9
  export declare function getCategoryGeneratedIndexMetadataList({ docs, sidebarsUtils, }: {
10
10
  sidebarsUtils: SidebarsUtils;
11
11
  docs: DocMetadataBase[];
@@ -18,6 +18,8 @@ function getCategoryGeneratedIndexMetadata({ category, sidebarsUtils, docsById,
18
18
  return {
19
19
  title: (_a = category.link.title) !== null && _a !== void 0 ? _a : category.label,
20
20
  description: category.link.description,
21
+ image: category.link.image,
22
+ keywords: category.link.keywords,
21
23
  slug: category.link.slug,
22
24
  permalink: category.link.permalink,
23
25
  sidebar: sidebarName,
package/lib/cli.d.ts CHANGED
@@ -4,5 +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
- import type { PathOptions, SidebarOptions } from './types';
7
+ import type { PathOptions, SidebarOptions } from '@docusaurus/plugin-content-docs';
8
8
  export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): void;
package/lib/cli.js CHANGED
@@ -13,6 +13,7 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const sidebars_1 = require("./sidebars");
15
15
  const utils_1 = require("@docusaurus/utils");
16
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
16
17
  function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
17
18
  // Load current sidebar and create a new versioned sidebars file (if needed).
18
19
  // Note: we don't need the sidebars file to be normalized: it's ok to let plugin option changes to impact older, versioned sidebars
@@ -80,6 +81,6 @@ function cliDocsVersionCommand(version, siteDir, pluginId, options) {
80
81
  versions.unshift(version);
81
82
  fs_extra_1.default.ensureDirSync(path_1.default.dirname(versionsJSONFile));
82
83
  fs_extra_1.default.writeFileSync(versionsJSONFile, `${JSON.stringify(versions, null, 2)}\n`);
83
- console.log(`${pluginIdLogPrefix}: version ${version} created!`);
84
+ logger_1.default.success `name=${pluginIdLogPrefix}: version name=${version} created!`;
84
85
  }
85
86
  exports.cliDocsVersionCommand = cliDocsVersionCommand;
@@ -4,28 +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 { GlobalPluginData, GlobalVersion, GlobalDoc } from '../types';
8
- declare type Version = GlobalVersion;
9
- declare type Doc = GlobalDoc;
10
- export declare type ActivePlugin = {
11
- pluginId: string;
12
- pluginData: GlobalPluginData;
13
- };
14
- export declare type GetActivePluginOptions = {
15
- failfast?: boolean;
16
- };
7
+ import type { GlobalPluginData, GlobalVersion, GetActivePluginOptions, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
17
8
  export declare function getActivePlugin(allPluginDatas: Record<string, GlobalPluginData>, pathname: string, options?: GetActivePluginOptions): ActivePlugin | undefined;
18
- export declare type ActiveDocContext = {
19
- activeVersion?: Version;
20
- activeDoc?: Doc;
21
- alternateDocVersions: Record<string, Doc>;
22
- };
23
- export declare const getLatestVersion: (data: GlobalPluginData) => Version;
24
- export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => Version | undefined;
9
+ export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
10
+ export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => GlobalVersion | undefined;
25
11
  export declare const getActiveDocContext: (data: GlobalPluginData, pathname: string) => ActiveDocContext;
26
- export declare type DocVersionSuggestions = {
27
- latestVersionSuggestion: GlobalVersion;
28
- latestDocSuggestion?: GlobalDoc;
29
- };
30
12
  export declare const getDocVersionSuggestions: (data: GlobalPluginData, pathname: string) => DocVersionSuggestions;
31
- export {};
@@ -8,11 +8,15 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getDocVersionSuggestions = exports.getActiveDocContext = exports.getActiveVersion = exports.getLatestVersion = exports.getActivePlugin = void 0;
10
10
  const router_1 = require("@docusaurus/router");
11
+ // This code is not part of the api surface, not in ./theme on purpose
11
12
  // get the data of the plugin that is currently "active"
12
13
  // ie the docs of that plugin are currently browsed
13
14
  // it is useful to support multiple docs plugin instances
14
15
  function getActivePlugin(allPluginDatas, pathname, options = {}) {
15
- const activeEntry = Object.entries(allPluginDatas).find(([_id, pluginData]) => !!(0, router_1.matchPath)(pathname, {
16
+ const activeEntry = Object.entries(allPluginDatas)
17
+ // A quick route sorting: '/android/foo' should match '/android' instead of '/'
18
+ .sort((a, b) => b[1].path.localeCompare(a[1].path))
19
+ .find(([, pluginData]) => !!(0, router_1.matchPath)(pathname, {
16
20
  path: pluginData.path,
17
21
  exact: false,
18
22
  strict: false,
@@ -4,8 +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 { GlobalPluginData, GlobalVersion } from '../../types';
8
- import { ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '../../client/docsClientUtils';
7
+ import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
9
8
  export declare const useAllDocsData: () => Record<string, GlobalPluginData>;
10
9
  export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
11
10
  export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
@@ -10,7 +10,7 @@ exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActi
10
10
  const tslib_1 = require("tslib");
11
11
  const router_1 = require("@docusaurus/router");
12
12
  const useGlobalData_1 = (0, tslib_1.__importStar)(require("@docusaurus/useGlobalData"));
13
- const docsClientUtils_1 = require("../../client/docsClientUtils");
13
+ const docsClientUtils_1 = require("./docsClientUtils");
14
14
  // Important to use a constant object to avoid React useEffect executions etc...,
15
15
  // see https://github.com/facebook/docusaurus/issues/5089
16
16
  const StableEmptyObject = {};
@@ -22,6 +22,7 @@ return (_a = (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs']) !
22
22
  exports.useAllDocsData = useAllDocsData;
23
23
  const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
24
24
  exports.useDocsData = useDocsData;
25
+ // TODO this feature should be provided by docusaurus core
25
26
  const useActivePlugin = (options = {}) => {
26
27
  const data = (0, exports.useAllDocsData)();
27
28
  const { pathname } = (0, router_1.useLocation)();
@@ -4,11 +4,4 @@
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
- module.exports = {
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
+ export * from './globalDataHooks';
@@ -1,14 +1,10 @@
1
+ "use strict";
1
2
  /**
2
3
  * Copyright (c) Facebook, Inc. and its affiliates.
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  */
7
-
8
- module.exports = {
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
- };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const tslib_1 = require("tslib");
10
+ (0, tslib_1.__exportStar)(require("./globalDataHooks"), exports);
@@ -24,6 +24,7 @@ const DocFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
24
24
  sidebar_label: utils_validation_1.JoiFrontMatter.string(),
25
25
  sidebar_position: utils_validation_1.JoiFrontMatter.number(),
26
26
  sidebar_class_name: utils_validation_1.JoiFrontMatter.string(),
27
+ displayed_sidebar: utils_validation_1.JoiFrontMatter.string().allow(null),
27
28
  tags: utils_validation_1.FrontMatterTagsSchema,
28
29
  pagination_label: utils_validation_1.JoiFrontMatter.string(),
29
30
  custom_edit_url: utils_validation_1.URISchema.allow('', null),
package/lib/docs.d.ts CHANGED
@@ -5,8 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext } from '@docusaurus/types';
8
- import { DocFile, DocMetadataBase, MetadataOptions, PluginOptions, VersionMetadata, LoadedVersion } from './types';
9
- import { SidebarsUtils } from './sidebars/utils';
8
+ import type { DocFile, DocMetadataBase, VersionMetadata, LoadedVersion } from './types';
9
+ import type { SidebarsUtils } from './sidebars/utils';
10
+ import type { MetadataOptions, PluginOptions, CategoryIndexMatcher, CategoryIndexMatcherParam } from '@docusaurus/plugin-content-docs';
10
11
  declare type LastUpdateOptions = Pick<PluginOptions, 'showLastUpdateAuthor' | 'showLastUpdateTime'>;
11
12
  export declare function readDocFile(versionMetadata: Pick<VersionMetadata, 'contentPath' | 'contentPathLocalized'>, source: string, options: LastUpdateOptions): Promise<DocFile>;
12
13
  export declare function readVersionDocs(versionMetadata: VersionMetadata, options: Pick<PluginOptions, 'include' | 'exclude' | 'showLastUpdateAuthor' | 'showLastUpdateTime'>): Promise<DocFile[]>;
@@ -28,10 +29,22 @@ export declare function getMainDocId({ docs, sidebarsUtils, }: {
28
29
  docs: DocMetadataBase[];
29
30
  sidebarsUtils: SidebarsUtils;
30
31
  }): string;
31
- export declare function isConventionalDocIndex(doc: {
32
- source: DocMetadataBase['slug'];
33
- sourceDirName: DocMetadataBase['sourceDirName'];
34
- }): boolean;
32
+ export declare const isCategoryIndex: CategoryIndexMatcher;
33
+ export declare function toCategoryIndexMatcherParam({ source, sourceDirName, }: Pick<DocMetadataBase, 'source' | 'sourceDirName'>): CategoryIndexMatcherParam;
34
+ /**
35
+ * guides/sidebar/autogenerated.md -> 'autogenerated', '.md', ['sidebar', 'guides']
36
+ */
37
+ export declare function splitPath(str: string): {
38
+ /**
39
+ * The list of directories, from lowest level to highest.
40
+ * If there's no dir name, directories is ['.']
41
+ */
42
+ directories: string[];
43
+ /** The file name, without extension */
44
+ fileName: string;
45
+ /** The extension, with a leading dot */
46
+ extension: string;
47
+ };
35
48
  export declare function getDocIds(doc: DocMetadataBase): [string, string];
36
49
  export declare function createDocsByIdIndex<Doc extends {
37
50
  id: string;
package/lib/docs.js CHANGED
@@ -6,11 +6,11 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createDocsByIdIndex = exports.getDocIds = exports.isConventionalDocIndex = exports.getMainDocId = exports.addDocNavigation = exports.processDocMetadata = exports.readVersionDocs = exports.readDocFile = void 0;
9
+ exports.createDocsByIdIndex = exports.getDocIds = exports.splitPath = exports.toCategoryIndexMatcherParam = exports.isCategoryIndex = exports.getMainDocId = exports.addDocNavigation = exports.processDocMetadata = exports.readVersionDocs = exports.readDocFile = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
14
  const lodash_1 = require("lodash");
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const lastUpdate_1 = require("./lastUpdate");
@@ -66,7 +66,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
66
66
  const frontMatter = (0, docFrontMatter_1.validateDocFrontMatter)(unsafeFrontMatter);
67
67
  const { custom_edit_url: customEditURL,
68
68
  // Strip number prefixes by default (01-MyFolder/01-MyDoc.md => MyFolder/MyDoc) by default,
69
- // but allow to disable this behavior with frontmatter
69
+ // but allow to disable this behavior with front matter
70
70
  parse_number_prefixes: parseNumberPrefixes = true, } = frontMatter;
71
71
  // ex: api/plugins/myDoc -> myDoc
72
72
  // ex: myDoc -> myDoc
@@ -81,7 +81,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
81
81
  if (baseID.includes('/')) {
82
82
  throw new Error(`Document id "${baseID}" cannot include slash.`);
83
83
  }
84
- // For autogenerated sidebars, sidebar position can come from filename number prefix or frontmatter
84
+ // For autogenerated sidebars, sidebar position can come from filename number prefix or front matter
85
85
  const sidebarPosition = (_b = frontMatter.sidebar_position) !== null && _b !== void 0 ? _b : numberPrefix;
86
86
  // TODO legacy retrocompatibility
87
87
  // The same doc in 2 distinct version could keep the same id,
@@ -90,7 +90,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
90
90
  ? undefined
91
91
  : `version-${versionMetadata.versionName}`;
92
92
  // TODO legacy retrocompatibility
93
- // I think it's bad to affect the frontmatter id with the dirname?
93
+ // I think it's bad to affect the front matter id with the dirname?
94
94
  function computeDirNameIdPrefix() {
95
95
  if (sourceDirName === '.') {
96
96
  return undefined;
@@ -110,7 +110,7 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
110
110
  baseID,
111
111
  source,
112
112
  sourceDirName,
113
- frontmatterSlug: frontMatter.slug,
113
+ frontMatterSlug: frontMatter.slug,
114
114
  stripDirNumberPrefixes: parseNumberPrefixes,
115
115
  numberPrefixParser: options.numberPrefixParser,
116
116
  });
@@ -171,7 +171,7 @@ function processDocMetadata(args) {
171
171
  return doProcessDocMetadata(args);
172
172
  }
173
173
  catch (e) {
174
- console.error(chalk_1.default.red(`Can't process doc metadata for doc at path "${args.docFile.filePath}" in version "${args.versionMetadata.versionName}"`));
174
+ logger_1.default.error `Can't process doc metadata for doc at path path=${args.docFile.filePath} in version name=${args.versionMetadata.versionName}`;
175
175
  throw e;
176
176
  }
177
177
  }
@@ -181,7 +181,7 @@ function addDocNavigation(docsBase, sidebarsUtils, sidebarFilePath) {
181
181
  sidebarsUtils.checkSidebarsDocIds(docsBase.flatMap(getDocIds), sidebarFilePath);
182
182
  // Add sidebar/next/previous to the docs
183
183
  function addNavData(doc) {
184
- const navigation = sidebarsUtils.getDocNavigation(doc.unversionedId, doc.id);
184
+ const navigation = sidebarsUtils.getDocNavigation(doc.unversionedId, doc.id, doc.frontMatter.displayed_sidebar);
185
185
  const toNavigationLinkByDocId = (docId, type) => {
186
186
  if (!docId) {
187
187
  return undefined;
@@ -193,10 +193,10 @@ function addDocNavigation(docsBase, sidebarsUtils, sidebarFilePath) {
193
193
  }
194
194
  return (0, utils_2.toDocNavigationLink)(navDoc);
195
195
  };
196
- const previous = doc.frontMatter.pagination_prev
196
+ const previous = doc.frontMatter.pagination_prev !== undefined
197
197
  ? toNavigationLinkByDocId(doc.frontMatter.pagination_prev, 'prev')
198
198
  : (0, utils_2.toNavigationLink)(navigation.previous, docsById);
199
- const next = doc.frontMatter.pagination_next
199
+ const next = doc.frontMatter.pagination_next !== undefined
200
200
  ? toNavigationLinkByDocId(doc.frontMatter.pagination_next, 'next')
201
201
  : (0, utils_2.toNavigationLink)(navigation.next, docsById);
202
202
  return { ...doc, sidebar: navigation.sidebarName, previous, next };
@@ -222,7 +222,8 @@ function getMainDocId({ docs, sidebarsUtils, }) {
222
222
  return versionHomeDoc;
223
223
  }
224
224
  else if (firstDocIdOfFirstSidebar) {
225
- return docs.find((doc) => doc.id === firstDocIdOfFirstSidebar);
225
+ return docs.find((doc) => doc.id === firstDocIdOfFirstSidebar ||
226
+ doc.unversionedId === firstDocIdOfFirstSidebar);
226
227
  }
227
228
  else {
228
229
  return docs[0];
@@ -231,26 +232,46 @@ function getMainDocId({ docs, sidebarsUtils, }) {
231
232
  return getMainDoc().unversionedId;
232
233
  }
233
234
  exports.getMainDocId = getMainDocId;
234
- function getLastPathSegment(str) {
235
- return (0, lodash_1.last)(str.split('/'));
236
- }
237
235
  // By convention, Docusaurus considers some docs are "indexes":
238
236
  // - index.md
239
237
  // - readme.md
240
238
  // - <folder>/<folder>.md
241
239
  //
240
+ // This function is the default implementation of this convention
241
+ //
242
242
  // Those index docs produce a different behavior
243
243
  // - Slugs do not end with a weird "/index" suffix
244
244
  // - Auto-generated sidebar categories link to them as intro
245
- function isConventionalDocIndex(doc) {
246
- // "@site/docs/folder/subFolder/subSubFolder/myDoc.md" => "myDoc"
247
- const docName = path_1.default.parse(doc.source).name;
248
- // "folder/subFolder/subSubFolder" => "subSubFolder"
249
- const lastDirName = getLastPathSegment(doc.sourceDirName);
250
- const eligibleDocIndexNames = ['index', 'readme', lastDirName.toLowerCase()];
251
- return eligibleDocIndexNames.includes(docName.toLowerCase());
245
+ const isCategoryIndex = ({ fileName, directories, }) => {
246
+ var _a;
247
+ const eligibleDocIndexNames = [
248
+ 'index',
249
+ 'readme',
250
+ (_a = directories[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
251
+ ];
252
+ return eligibleDocIndexNames.includes(fileName.toLowerCase());
253
+ };
254
+ exports.isCategoryIndex = isCategoryIndex;
255
+ function toCategoryIndexMatcherParam({ source, sourceDirName, }) {
256
+ // source + sourceDirName are always posix-style
257
+ return {
258
+ fileName: path_1.default.posix.parse(source).name,
259
+ extension: path_1.default.posix.parse(source).ext,
260
+ directories: sourceDirName.split(path_1.default.posix.sep).reverse(),
261
+ };
262
+ }
263
+ exports.toCategoryIndexMatcherParam = toCategoryIndexMatcherParam;
264
+ /**
265
+ * guides/sidebar/autogenerated.md -> 'autogenerated', '.md', ['sidebar', 'guides']
266
+ */
267
+ function splitPath(str) {
268
+ return {
269
+ fileName: path_1.default.parse(str).name,
270
+ extension: path_1.default.parse(str).ext,
271
+ directories: path_1.default.dirname(str).split(path_1.default.sep).reverse(),
272
+ };
252
273
  }
253
- exports.isConventionalDocIndex = isConventionalDocIndex;
274
+ exports.splitPath = splitPath;
254
275
  // Return both doc ids
255
276
  // TODO legacy retro-compatibility due to old versioned sidebars using versioned doc ids
256
277
  // ("id" should be removed & "versionedId" should be renamed to "id")
@@ -4,6 +4,10 @@
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 { DocMetadata, GlobalDoc, LoadedVersion, GlobalVersion } from './types';
7
+ import type { Sidebars } from './sidebars/types';
8
+ import type { CategoryGeneratedIndexMetadata, DocMetadata, LoadedVersion } from './types';
9
+ import type { GlobalVersion, GlobalSidebar, GlobalDoc } from '@docusaurus/plugin-content-docs/client';
8
10
  export declare function toGlobalDataDoc(doc: DocMetadata): GlobalDoc;
11
+ export declare function toGlobalDataGeneratedIndex(doc: CategoryGeneratedIndexMetadata): GlobalDoc;
12
+ export declare function toGlobalSidebars(sidebars: Sidebars, version: LoadedVersion): Record<string, GlobalSidebar>;
9
13
  export declare function toGlobalDataVersion(version: LoadedVersion): GlobalVersion;
package/lib/globalData.js CHANGED
@@ -6,7 +6,10 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.toGlobalDataVersion = exports.toGlobalDataDoc = void 0;
9
+ exports.toGlobalDataVersion = exports.toGlobalSidebars = exports.toGlobalDataGeneratedIndex = exports.toGlobalDataDoc = void 0;
10
+ const lodash_1 = require("lodash");
11
+ const utils_1 = require("@docusaurus/utils");
12
+ const utils_2 = require("./sidebars/utils");
10
13
  function toGlobalDataDoc(doc) {
11
14
  return {
12
15
  id: doc.unversionedId,
@@ -15,6 +18,32 @@ function toGlobalDataDoc(doc) {
15
18
  };
16
19
  }
17
20
  exports.toGlobalDataDoc = toGlobalDataDoc;
21
+ function toGlobalDataGeneratedIndex(doc) {
22
+ return {
23
+ id: doc.slug,
24
+ path: doc.permalink,
25
+ sidebar: doc.sidebar,
26
+ };
27
+ }
28
+ exports.toGlobalDataGeneratedIndex = toGlobalDataGeneratedIndex;
29
+ function toGlobalSidebars(sidebars, version) {
30
+ const { getFirstLink } = (0, utils_2.createSidebarsUtils)(sidebars);
31
+ return (0, lodash_1.mapValues)(sidebars, (sidebar, sidebarId) => {
32
+ const firstLink = getFirstLink(sidebarId);
33
+ if (!firstLink) {
34
+ return {};
35
+ }
36
+ return {
37
+ link: {
38
+ path: firstLink.type === 'generated-index'
39
+ ? (0, utils_1.normalizeUrl)([version.versionPath, firstLink.slug])
40
+ : version.docs.find((doc) => doc.id === firstLink.id || doc.unversionedId === firstLink.id).permalink,
41
+ label: firstLink.label,
42
+ },
43
+ };
44
+ });
45
+ }
46
+ exports.toGlobalSidebars = toGlobalSidebars;
18
47
  function toGlobalDataVersion(version) {
19
48
  return {
20
49
  name: version.versionName,
@@ -22,7 +51,10 @@ function toGlobalDataVersion(version) {
22
51
  isLast: version.isLast,
23
52
  path: version.versionPath,
24
53
  mainDocId: version.mainDocId,
25
- docs: version.docs.map(toGlobalDataDoc),
54
+ docs: version.docs
55
+ .map(toGlobalDataDoc)
56
+ .concat(version.categoryGeneratedIndices.map(toGlobalDataGeneratedIndex)),
57
+ sidebars: toGlobalSidebars(version.sidebars, version),
26
58
  };
27
59
  }
28
60
  exports.toGlobalDataVersion = toGlobalDataVersion;
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext, Plugin } from '@docusaurus/types';
8
- import { PluginOptions, LoadedContent } from './types';
9
- export default function pluginContentDocs(context: LoadContext, options: PluginOptions): Plugin<LoadedContent>;
8
+ import type { LoadedContent } from './types';
9
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
10
+ export default function pluginContentDocs(context: LoadContext, options: PluginOptions): Promise<Plugin<LoadedContent>>;
10
11
  export { validateOptions } from './options';
package/lib/index.js CHANGED
@@ -20,27 +20,21 @@ const lodash_1 = require("lodash");
20
20
  const globalData_1 = require("./globalData");
21
21
  const props_1 = require("./props");
22
22
  const translations_1 = require("./translations");
23
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
23
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
24
24
  const tags_1 = require("./tags");
25
25
  const routes_1 = require("./routes");
26
26
  const utils_2 = require("./sidebars/utils");
27
27
  const categoryGeneratedIndex_1 = require("./categoryGeneratedIndex");
28
- function pluginContentDocs(context, options) {
28
+ async function pluginContentDocs(context, options) {
29
29
  var _a;
30
30
  const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
31
- const versionsMetadata = (0, versions_1.readVersionsMetadata)({ context, options });
31
+ const versionsMetadata = await (0, versions_1.readVersionsMetadata)({ context, options });
32
32
  const pluginId = (_a = options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID;
33
33
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
34
34
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
35
35
  const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
36
36
  return {
37
37
  name: 'docusaurus-plugin-content-docs',
38
- getThemePath() {
39
- return path_1.default.resolve(__dirname, './theme');
40
- },
41
- getTypeScriptThemePath() {
42
- return path_1.default.resolve(__dirname, '..', 'src', 'theme');
43
- },
44
38
  extendCli(cli) {
45
39
  const isDefaultPluginId = pluginId === utils_1.DEFAULT_PLUGIN_ID;
46
40
  // Need to create one distinct command per plugin instance
@@ -126,7 +120,7 @@ function pluginContentDocs(context, options) {
126
120
  return await doLoadVersion(versionMetadata);
127
121
  }
128
122
  catch (e) {
129
- console.error(chalk_1.default.red(`Loading of version failed for version "${versionMetadata.versionName}"`));
123
+ logger_1.default.error `Loading of version failed for version name=${versionMetadata.versionName}`;
130
124
  throw e;
131
125
  }
132
126
  }
package/lib/lastUpdate.js CHANGED
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getFileLastUpdate = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
13
  const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),(.+)$/;
13
14
  let showedGitRequirementError = false;
14
15
  async function getFileLastUpdate(filePath) {
@@ -30,20 +31,20 @@ async function getFileLastUpdate(filePath) {
30
31
  if (!shelljs_1.default.which('git')) {
31
32
  if (!showedGitRequirementError) {
32
33
  showedGitRequirementError = true;
33
- console.warn('Sorry, the docs plugin last update options require Git.');
34
+ logger_1.default.warn('Sorry, the docs plugin last update options require Git.');
34
35
  }
35
36
  return null;
36
37
  }
37
- const result = shelljs_1.default.exec(`git log -1 --format=%ct,%an ${filePath}`, {
38
+ const result = shelljs_1.default.exec(`git log -1 --format=%ct,%an "${filePath}"`, {
38
39
  silent: true,
39
40
  });
40
41
  if (result.code !== 0) {
41
- throw new Error(`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`);
42
+ throw new Error(`Retrieval of git history failed at "${filePath}" with exit code ${result.code}: ${result.stderr}`);
42
43
  }
43
44
  return getTimestampAndAuthor(result.stdout.trim());
44
45
  }
45
- catch (error) {
46
- console.error(error);
46
+ catch (e) {
47
+ logger_1.default.error(e);
47
48
  }
48
49
  return null;
49
50
  }
@@ -4,6 +4,6 @@
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 { DocsMarkdownOption } from '../types';
7
+ import type { DocsMarkdownOption } from '../types';
8
8
  import type { LoaderContext } from 'webpack';
9
9
  export default function markdownLoader(this: LoaderContext<DocsMarkdownOption>, source: string): void;
@@ -4,5 +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
- import { DocsMarkdownOption } from '../types';
7
+ import type { DocsMarkdownOption } from '../types';
8
8
  export declare function linkify(fileString: string, filePath: string, options: DocsMarkdownOption): string;
@@ -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 type { NumberPrefixParser } from './types';
7
+ import type { NumberPrefixParser } from '@docusaurus/plugin-content-docs';
8
8
  export declare const DefaultNumberPrefixParser: NumberPrefixParser;
9
9
  export declare const DisabledNumberPrefixParser: NumberPrefixParser;
10
10
  export declare function stripNumberPrefix(str: string, parser: NumberPrefixParser): string;
package/lib/options.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 type { PluginOptions } from './types';
7
+ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
9
  import type { OptionValidationContext, ValidationResult } from '@docusaurus/types';
10
10
  export declare const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'>;
package/lib/options.js CHANGED
@@ -10,7 +10,7 @@ exports.validateOptions = exports.OptionsSchema = exports.DEFAULT_OPTIONS = void
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
12
  const utils_1 = require("@docusaurus/utils");
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
14
  const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admonitions"));
15
15
  const generator_1 = require("./sidebars/generator");
16
16
  const numberPrefix_1 = require("./numberPrefix");
@@ -111,7 +111,7 @@ function validateOptions({ validate, options: userOptions, }) {
111
111
  };
112
112
  }
113
113
  if (options.sidebarCollapsed) {
114
- console.warn(chalk_1.default.yellow('The docs plugin config is inconsistent. It does not make sense to use sidebarCollapsible=false and sidebarCollapsed=true at the same time. sidebarCollapsed=false will be ignored.'));
114
+ logger_1.default.warn `The docs plugin config is inconsistent. It does not make sense to use code=${'sidebarCollapsible: false'} and code=${'sidebarCollapsed: true'} at the same time. code=${'sidebarCollapsed: true'} will be ignored.`;
115
115
  options = {
116
116
  ...options,
117
117
  sidebarCollapsed: false,
package/lib/routes.d.ts CHANGED
@@ -4,12 +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 { PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
8
- import { DocMetadata, LoadedVersion } from './types';
9
- export declare function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, }: {
7
+ import type { PluginContentLoadedActions, RouteConfig } from '@docusaurus/types';
8
+ import type { DocMetadata, LoadedVersion } from './types';
9
+ export declare function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, aliasedSource, }: {
10
10
  version: LoadedVersion;
11
11
  actions: PluginContentLoadedActions;
12
12
  docCategoryGeneratedIndexComponent: string;
13
+ aliasedSource: (str: string) => string;
13
14
  }): Promise<RouteConfig[]>;
14
15
  export declare function createDocRoutes({ docs, actions, docItemComponent, }: {
15
16
  docs: DocMetadata[];
package/lib/routes.js CHANGED
@@ -10,17 +10,19 @@ exports.createVersionRoutes = exports.createDocRoutes = exports.createCategoryGe
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
12
  const props_1 = require("./props");
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
14
- async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, }) {
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
+ async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, aliasedSource, }) {
15
15
  const slugs = (0, utils_1.createSlugger)();
16
16
  async function createCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
17
- const { sidebar, title, description, slug, permalink, previous, next } = categoryGeneratedIndex;
17
+ const { sidebar, title, description, slug, permalink, previous, next, image, keywords, } = categoryGeneratedIndex;
18
18
  const propFileName = slugs.slug(`${version.versionPath}-${categoryGeneratedIndex.sidebar}-category-${categoryGeneratedIndex.title}`);
19
19
  const prop = {
20
20
  title,
21
21
  description,
22
22
  slug,
23
23
  permalink,
24
+ image,
25
+ keywords,
24
26
  navigation: {
25
27
  previous,
26
28
  next,
@@ -32,7 +34,7 @@ async function createCategoryGeneratedIndexRoutes({ version, actions, docCategor
32
34
  component: docCategoryGeneratedIndexComponent,
33
35
  exact: true,
34
36
  modules: {
35
- categoryGeneratedIndex: propData,
37
+ categoryGeneratedIndex: aliasedSource(propData),
36
38
  },
37
39
  // Same as doc, this sidebar route attribute permits to associate this subpage to the given sidebar
38
40
  ...(sidebar && { sidebar }),
@@ -75,6 +77,7 @@ async function createVersionRoutes({ loadedVersion, actions, docItemComponent, d
75
77
  version,
76
78
  actions,
77
79
  docCategoryGeneratedIndexComponent,
80
+ aliasedSource,
78
81
  }),
79
82
  ]);
80
83
  const routes = [...docRoutes, ...sidebarsRoutes];
@@ -98,7 +101,7 @@ async function createVersionRoutes({ loadedVersion, actions, docItemComponent, d
98
101
  return await doCreateVersionRoutes(loadedVersion);
99
102
  }
100
103
  catch (e) {
101
- console.error(chalk_1.default.red(`Can't create version routes for version "${loadedVersion.versionName}"`));
104
+ logger_1.default.error `Can't create version routes for version name=${loadedVersion.versionName}`;
102
105
  throw e;
103
106
  }
104
107
  }