@docusaurus/plugin-content-docs 2.0.0-beta.12faed89d → 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.
Files changed (200) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +12 -0
  2. package/lib/categoryGeneratedIndex.js +37 -0
  3. package/lib/cli.d.ts +2 -2
  4. package/lib/cli.js +14 -35
  5. package/lib/client/docsClientUtils.d.ts +0 -3
  6. package/lib/client/docsClientUtils.js +19 -22
  7. package/lib/docFrontMatter.d.ts +1 -1
  8. package/lib/docFrontMatter.js +7 -3
  9. package/lib/docs.d.ts +25 -3
  10. package/lib/docs.js +126 -41
  11. package/lib/globalData.d.ts +1 -1
  12. package/lib/index.d.ts +1 -1
  13. package/lib/index.js +101 -132
  14. package/lib/lastUpdate.js +12 -12
  15. package/lib/markdown/index.d.ts +3 -6
  16. package/lib/markdown/index.js +3 -3
  17. package/lib/markdown/linkify.js +2 -2
  18. package/lib/numberPrefix.d.ts +1 -1
  19. package/lib/options.d.ts +3 -3
  20. package/lib/options.js +48 -11
  21. package/lib/props.d.ts +7 -2
  22. package/lib/props.js +60 -8
  23. package/lib/routes.d.ts +27 -0
  24. package/lib/routes.js +105 -0
  25. package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +5 -2
  26. package/lib/sidebars/generator.js +216 -0
  27. package/lib/sidebars/index.d.ts +15 -0
  28. package/lib/sidebars/index.js +73 -0
  29. package/lib/sidebars/normalization.d.ts +14 -0
  30. package/lib/sidebars/normalization.js +77 -0
  31. package/lib/sidebars/processor.d.ts +18 -0
  32. package/lib/sidebars/processor.js +85 -0
  33. package/lib/sidebars/types.d.ts +127 -0
  34. package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
  35. package/lib/sidebars/utils.d.ts +35 -0
  36. package/lib/sidebars/utils.js +228 -0
  37. package/lib/sidebars/validation.d.ts +10 -0
  38. package/lib/sidebars/validation.js +138 -0
  39. package/lib/slug.d.ts +4 -3
  40. package/lib/slug.js +27 -15
  41. package/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/tags.d.ts} +2 -8
  42. package/lib/tags.js +20 -0
  43. package/lib/theme/hooks/useDocs.js +21 -21
  44. package/lib/translations.d.ts +2 -2
  45. package/lib/translations.js +71 -29
  46. package/lib/types.d.ts +52 -63
  47. package/lib/versions.d.ts +3 -3
  48. package/lib/versions.js +41 -22
  49. package/package.json +20 -20
  50. package/src/categoryGeneratedIndex.ts +57 -0
  51. package/src/cli.ts +10 -42
  52. package/src/client/docsClientUtils.ts +14 -26
  53. package/{types.d.ts → src/deps.d.ts} +0 -0
  54. package/src/docFrontMatter.ts +9 -4
  55. package/src/docs.ts +164 -36
  56. package/src/globalData.ts +6 -1
  57. package/src/index.ts +127 -175
  58. package/src/lastUpdate.ts +14 -16
  59. package/src/markdown/index.ts +8 -12
  60. package/src/numberPrefix.ts +5 -3
  61. package/src/options.ts +56 -15
  62. package/src/plugin-content-docs.d.ts +173 -40
  63. package/src/props.ts +90 -15
  64. package/src/routes.ts +169 -0
  65. package/src/sidebars/generator.ts +302 -0
  66. package/src/sidebars/index.ts +94 -0
  67. package/src/sidebars/normalization.ts +112 -0
  68. package/src/sidebars/processor.ts +154 -0
  69. package/src/sidebars/types.ts +211 -0
  70. package/src/sidebars/utils.ts +329 -0
  71. package/src/sidebars/validation.ts +168 -0
  72. package/src/slug.ts +32 -17
  73. package/src/tags.ts +19 -0
  74. package/src/translations.ts +103 -47
  75. package/src/types.ts +64 -107
  76. package/src/versions.ts +59 -25
  77. package/lib/.tsbuildinfo +0 -1
  78. package/lib/sidebarItemsGenerator.js +0 -211
  79. package/lib/sidebars.d.ts +0 -43
  80. package/lib/sidebars.js +0 -320
  81. package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
  82. package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
  83. package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
  84. package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
  85. package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
  86. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
  87. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
  88. package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
  89. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
  90. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
  91. package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
  92. package/src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
  93. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
  94. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
  95. package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
  96. package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
  97. package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
  98. package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
  99. package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
  100. package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -70
  101. package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
  102. package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -53
  103. package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
  104. package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
  105. package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
  106. package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
  107. package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
  108. package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
  109. package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
  110. package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
  111. package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
  112. package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
  113. package/src/__tests__/__fixtures__/simple-site/docusaurus.config.js +0 -14
  114. package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
  115. package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
  116. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
  117. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
  118. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
  119. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
  120. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
  121. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
  122. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
  123. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
  124. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
  125. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
  126. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
  127. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
  128. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
  129. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
  130. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
  131. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
  132. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
  133. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js +0 -14
  134. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
  135. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
  136. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
  137. package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
  138. package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
  139. package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
  140. package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
  141. package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
  142. package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
  143. package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
  144. package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
  145. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
  146. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
  147. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
  148. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
  149. package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
  150. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  151. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
  152. package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  153. package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
  154. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
  155. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
  156. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
  157. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
  158. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
  159. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
  160. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
  161. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
  162. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
  163. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
  164. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
  165. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
  166. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
  167. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  168. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
  169. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
  170. package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
  171. package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
  172. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1902
  173. package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
  174. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -484
  175. package/src/__tests__/cli.test.ts +0 -333
  176. package/src/__tests__/docFrontMatter.test.ts +0 -244
  177. package/src/__tests__/docs.test.ts +0 -878
  178. package/src/__tests__/index.test.ts +0 -1868
  179. package/src/__tests__/lastUpdate.test.ts +0 -69
  180. package/src/__tests__/numberPrefix.test.ts +0 -199
  181. package/src/__tests__/options.test.ts +0 -231
  182. package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
  183. package/src/__tests__/sidebars.test.ts +0 -639
  184. package/src/__tests__/slug.test.ts +0 -109
  185. package/src/__tests__/translations.test.ts +0 -158
  186. package/src/__tests__/versions.test.ts +0 -741
  187. package/src/client/__tests__/docsClientUtils.test.ts +0 -371
  188. package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
  189. package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
  190. package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
  191. package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
  192. package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
  193. package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
  194. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
  195. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
  196. package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
  197. package/src/markdown/__tests__/linkify.test.ts +0 -190
  198. package/src/sidebarItemsGenerator.ts +0 -307
  199. package/src/sidebars.ts +0 -522
  200. package/tsconfig.json +0 -9
package/lib/index.js CHANGED
@@ -8,28 +8,31 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateOptions = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = tslib_1.__importDefault(require("path"));
12
- const constants_1 = require("@docusaurus/core/lib/constants");
11
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
12
  const utils_1 = require("@docusaurus/utils");
14
13
  const sidebars_1 = require("./sidebars");
14
+ const generator_1 = require("./sidebars/generator");
15
15
  const docs_1 = require("./docs");
16
16
  const versions_1 = require("./versions");
17
17
  const cli_1 = require("./cli");
18
- const constants_2 = require("./constants");
18
+ const constants_1 = require("./constants");
19
19
  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 sidebarItemsGenerator_1 = require("./sidebarItemsGenerator");
24
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
23
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
24
+ const tags_1 = require("./tags");
25
+ const routes_1 = require("./routes");
26
+ const utils_2 = require("./sidebars/utils");
27
+ const categoryGeneratedIndex_1 = require("./categoryGeneratedIndex");
25
28
  function pluginContentDocs(context, options) {
26
29
  var _a;
27
30
  const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
28
- const versionsMetadata = versions_1.readVersionsMetadata({ context, options });
29
- const pluginId = (_a = options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID;
31
+ const versionsMetadata = (0, versions_1.readVersionsMetadata)({ context, options });
32
+ const pluginId = (_a = options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID;
30
33
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
31
34
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
32
- const aliasedSource = (source) => `~docs/${utils_1.posixPath(path_1.default.relative(pluginDataDirRoot, source))}`;
35
+ const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
33
36
  return {
34
37
  name: 'docusaurus-plugin-content-docs',
35
38
  getThemePath() {
@@ -39,7 +42,7 @@ function pluginContentDocs(context, options) {
39
42
  return path_1.default.resolve(__dirname, '..', 'src', 'theme');
40
43
  },
41
44
  extendCli(cli) {
42
- const isDefaultPluginId = pluginId === constants_1.DEFAULT_PLUGIN_ID;
45
+ const isDefaultPluginId = pluginId === utils_1.DEFAULT_PLUGIN_ID;
43
46
  // Need to create one distinct command per plugin instance
44
47
  // otherwise 2 instances would try to execute the command!
45
48
  const command = isDefaultPluginId
@@ -53,43 +56,38 @@ function pluginContentDocs(context, options) {
53
56
  .arguments('<version>')
54
57
  .description(commandDescription)
55
58
  .action((version) => {
56
- cli_1.cliDocsVersionCommand(version, siteDir, pluginId, {
59
+ (0, cli_1.cliDocsVersionCommand)(version, siteDir, pluginId, {
57
60
  path: options.path,
58
61
  sidebarPath: options.sidebarPath,
62
+ sidebarCollapsed: options.sidebarCollapsed,
63
+ sidebarCollapsible: options.sidebarCollapsible,
59
64
  });
60
65
  });
61
66
  },
62
67
  async getTranslationFiles({ content }) {
63
- return translations_1.getLoadedContentTranslationFiles(content);
64
- },
65
- getClientModules() {
66
- const modules = [];
67
- if (options.admonitions) {
68
- modules.push(require.resolve('remark-admonitions/styles/infima.css'));
69
- }
70
- return modules;
68
+ return (0, translations_1.getLoadedContentTranslationFiles)(content);
71
69
  },
72
70
  getPathsToWatch() {
73
71
  function getVersionPathsToWatch(version) {
74
72
  const result = [
75
- ...lodash_1.flatten(options.include.map((pattern) => versions_1.getDocsDirPaths(version).map((docsDirPath) => `${docsDirPath}/${pattern}`))),
76
- `${version.contentPath}/**/${sidebarItemsGenerator_1.CategoryMetadataFilenamePattern}`,
73
+ ...options.include.flatMap((pattern) => (0, versions_1.getDocsDirPaths)(version).map((docsDirPath) => `${docsDirPath}/${pattern}`)),
74
+ `${version.contentPath}/**/${generator_1.CategoryMetadataFilenamePattern}`,
77
75
  ];
78
76
  if (typeof version.sidebarFilePath === 'string') {
79
77
  result.unshift(version.sidebarFilePath);
80
78
  }
81
79
  return result;
82
80
  }
83
- return lodash_1.flatten(versionsMetadata.map(getVersionPathsToWatch));
81
+ return versionsMetadata.flatMap(getVersionPathsToWatch);
84
82
  },
85
83
  async loadContent() {
86
84
  async function loadVersionDocsBase(versionMetadata) {
87
- const docFiles = await docs_1.readVersionDocs(versionMetadata, options);
85
+ const docFiles = await (0, docs_1.readVersionDocs)(versionMetadata, options);
88
86
  if (docFiles.length === 0) {
89
87
  throw new Error(`Docs version "${versionMetadata.versionName}" has no docs! At least one doc should exist at "${path_1.default.relative(siteDir, versionMetadata.contentPath)}".`);
90
88
  }
91
89
  async function processVersionDoc(docFile) {
92
- return docs_1.processDocMetadata({
90
+ return (0, docs_1.processDocMetadata)({
93
91
  docFile,
94
92
  versionMetadata,
95
93
  context,
@@ -99,63 +97,28 @@ function pluginContentDocs(context, options) {
99
97
  return Promise.all(docFiles.map(processVersionDoc));
100
98
  }
101
99
  async function doLoadVersion(versionMetadata) {
102
- const unprocessedSidebars = sidebars_1.loadSidebars(versionMetadata.sidebarFilePath);
103
- const docsBase = await loadVersionDocsBase(versionMetadata);
104
- const docsBaseById = lodash_1.keyBy(docsBase, (doc) => doc.id);
105
- const sidebars = await sidebars_1.processSidebars({
100
+ const docs = await loadVersionDocsBase(versionMetadata);
101
+ const sidebars = await (0, sidebars_1.loadSidebars)(versionMetadata.sidebarFilePath, {
106
102
  sidebarItemsGenerator: options.sidebarItemsGenerator,
107
103
  numberPrefixParser: options.numberPrefixParser,
108
- unprocessedSidebars,
109
- docs: docsBase,
104
+ docs,
110
105
  version: versionMetadata,
106
+ sidebarOptions: {
107
+ sidebarCollapsed: options.sidebarCollapsed,
108
+ sidebarCollapsible: options.sidebarCollapsible,
109
+ },
110
+ categoryLabelSlugger: (0, utils_1.createSlugger)(),
111
111
  });
112
- const sidebarsUtils = sidebars_1.createSidebarsUtils(sidebars);
113
- const validDocIds = Object.keys(docsBaseById);
114
- sidebarsUtils.checkSidebarsDocIds(validDocIds, versionMetadata.sidebarFilePath);
115
- // Add sidebar/next/previous to the docs
116
- function addNavData(doc) {
117
- const { sidebarName, previousId, nextId, } = sidebarsUtils.getDocNavigation(doc.id);
118
- const toDocNavLink = (navDocId) => {
119
- var _a, _b;
120
- const { title, permalink, frontMatter } = docsBaseById[navDocId];
121
- return {
122
- title: (_b = (_a = frontMatter.pagination_label) !== null && _a !== void 0 ? _a : frontMatter.sidebar_label) !== null && _b !== void 0 ? _b : title,
123
- permalink,
124
- };
125
- };
126
- return {
127
- ...doc,
128
- sidebar: sidebarName,
129
- previous: previousId ? toDocNavLink(previousId) : undefined,
130
- next: nextId ? toDocNavLink(nextId) : undefined,
131
- };
132
- }
133
- const docs = docsBase.map(addNavData);
134
- // sort to ensure consistent output for tests
135
- docs.sort((a, b) => a.id.localeCompare(b.id));
136
- // The "main doc" is the "version entry point"
137
- // We browse this doc by clicking on a version:
138
- // - the "home" doc (at '/docs/')
139
- // - the first doc of the first sidebar
140
- // - a random doc (if no docs are in any sidebar... edge case)
141
- function getMainDoc() {
142
- const versionHomeDoc = docs.find((doc) => doc.unversionedId === options.homePageId || doc.slug === '/');
143
- const firstDocIdOfFirstSidebar = sidebarsUtils.getFirstDocIdOfFirstSidebar();
144
- if (versionHomeDoc) {
145
- return versionHomeDoc;
146
- }
147
- else if (firstDocIdOfFirstSidebar) {
148
- return docs.find((doc) => doc.id === firstDocIdOfFirstSidebar);
149
- }
150
- else {
151
- return docs[0];
152
- }
153
- }
112
+ const sidebarsUtils = (0, utils_2.createSidebarsUtils)(sidebars);
154
113
  return {
155
114
  ...versionMetadata,
156
- mainDocId: getMainDoc().unversionedId,
115
+ docs: (0, docs_1.addDocNavigation)(docs, sidebarsUtils, versionMetadata.sidebarFilePath),
157
116
  sidebars,
158
- docs: docs.map(addNavData),
117
+ mainDocId: (0, docs_1.getMainDocId)({ docs, sidebarsUtils }),
118
+ categoryGeneratedIndices: (0, categoryGeneratedIndex_1.getCategoryGeneratedIndexMetadataList)({
119
+ docs,
120
+ sidebarsUtils,
121
+ }),
159
122
  };
160
123
  }
161
124
  async function loadVersion(versionMetadata) {
@@ -163,7 +126,7 @@ function pluginContentDocs(context, options) {
163
126
  return await doLoadVersion(versionMetadata);
164
127
  }
165
128
  catch (e) {
166
- console.error(chalk_1.default.red(`Loading of version failed for version "${versionMetadata.versionName}"`));
129
+ logger_1.default.error `Loading of version failed for version name=${versionMetadata.versionName}`;
167
130
  throw e;
168
131
  }
169
132
  }
@@ -172,64 +135,67 @@ function pluginContentDocs(context, options) {
172
135
  };
173
136
  },
174
137
  translateContent({ content, translationFiles }) {
175
- return translations_1.translateLoadedContent(content, translationFiles);
138
+ return (0, translations_1.translateLoadedContent)(content, translationFiles);
176
139
  },
177
140
  async contentLoaded({ content, actions }) {
178
141
  const { loadedVersions } = content;
179
- const { docLayoutComponent, docItemComponent } = options;
142
+ const { docLayoutComponent, docItemComponent, docCategoryGeneratedIndexComponent, } = options;
180
143
  const { addRoute, createData, setGlobalData } = actions;
181
- const createDocRoutes = async (docs) => {
182
- const routes = await Promise.all(docs.map(async (metadataItem) => {
183
- await createData(
184
- // Note that this created data path must be in sync with
185
- // metadataPath provided to mdx-loader.
186
- `${utils_1.docuHash(metadataItem.source)}.json`, JSON.stringify(metadataItem, null, 2));
187
- const docRoute = {
188
- path: metadataItem.permalink,
189
- component: docItemComponent,
144
+ async function createVersionTagsRoutes(version) {
145
+ const versionTags = (0, tags_1.getVersionTags)(version.docs);
146
+ // TODO tags should be a sub route of the version route
147
+ async function createTagsListPage() {
148
+ const tagsProp = Object.values(versionTags).map((tagValue) => ({
149
+ name: tagValue.name,
150
+ permalink: tagValue.permalink,
151
+ count: tagValue.docIds.length,
152
+ }));
153
+ // Only create /tags page if there are tags.
154
+ if (Object.keys(tagsProp).length > 0) {
155
+ const tagsPropPath = await createData(`${(0, utils_1.docuHash)(`tags-list-${version.versionName}-prop`)}.json`, JSON.stringify(tagsProp, null, 2));
156
+ addRoute({
157
+ path: version.tagsPath,
158
+ exact: true,
159
+ component: options.docTagsListComponent,
160
+ modules: {
161
+ tags: aliasedSource(tagsPropPath),
162
+ },
163
+ });
164
+ }
165
+ }
166
+ // TODO tags should be a sub route of the version route
167
+ async function createTagDocListPage(tag) {
168
+ const tagProps = (0, props_1.toTagDocListProp)({
169
+ allTagsPath: version.tagsPath,
170
+ tag,
171
+ docs: version.docs,
172
+ });
173
+ const tagPropPath = await createData(`${(0, utils_1.docuHash)(`tag-${tag.permalink}`)}.json`, JSON.stringify(tagProps, null, 2));
174
+ addRoute({
175
+ path: tag.permalink,
176
+ component: options.docTagDocListComponent,
190
177
  exact: true,
191
178
  modules: {
192
- content: metadataItem.source,
179
+ tag: aliasedSource(tagPropPath),
193
180
  },
194
- // Because the parent (DocPage) comp need to access it easily
195
- // This permits to render the sidebar once without unmount/remount when navigating (and preserve sidebar state)
196
- ...(metadataItem.sidebar && {
197
- sidebar: metadataItem.sidebar,
198
- }),
199
- };
200
- return docRoute;
201
- }));
202
- return routes.sort((a, b) => a.path.localeCompare(b.path));
203
- };
204
- async function doCreateVersionRoutes(loadedVersion) {
205
- const versionMetadata = props_1.toVersionMetadataProp(pluginId, loadedVersion);
206
- const versionMetadataPropPath = await createData(`${utils_1.docuHash(`version-${loadedVersion.versionName}-metadata-prop`)}.json`, JSON.stringify(versionMetadata, null, 2));
207
- addRoute({
208
- path: loadedVersion.versionPath,
209
- // allow matching /docs/* as well
210
- exact: false,
211
- // main docs component (DocPage)
212
- component: docLayoutComponent,
213
- // sub-routes for each doc
214
- routes: await createDocRoutes(loadedVersion.docs),
215
- modules: {
216
- versionMetadata: aliasedSource(versionMetadataPropPath),
217
- },
218
- priority: loadedVersion.routePriority,
219
- });
220
- }
221
- async function createVersionRoutes(loadedVersion) {
222
- try {
223
- return await doCreateVersionRoutes(loadedVersion);
224
- }
225
- catch (e) {
226
- console.error(chalk_1.default.red(`Can't create version routes for version "${loadedVersion.versionName}"`));
227
- throw e;
181
+ });
228
182
  }
183
+ await createTagsListPage();
184
+ await Promise.all(Object.values(versionTags).map(createTagDocListPage));
229
185
  }
230
- await Promise.all(loadedVersions.map(createVersionRoutes));
186
+ await Promise.all(loadedVersions.map((loadedVersion) => (0, routes_1.createVersionRoutes)({
187
+ loadedVersion,
188
+ docItemComponent,
189
+ docLayoutComponent,
190
+ docCategoryGeneratedIndexComponent,
191
+ pluginId,
192
+ aliasedSource,
193
+ actions,
194
+ })));
195
+ // TODO tags should be a sub route of the version route
196
+ await Promise.all(loadedVersions.map(createVersionTagsRoutes));
231
197
  setGlobalData({
232
- path: utils_1.normalizeUrl([baseUrl, options.routeBasePath]),
198
+ path: (0, utils_1.normalizeUrl)([baseUrl, options.routeBasePath]),
233
199
  versions: loadedVersions.map(globalData_1.toGlobalDataVersion),
234
200
  });
235
201
  },
@@ -237,8 +203,8 @@ function pluginContentDocs(context, options) {
237
203
  const { getJSLoader } = utils;
238
204
  const { rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
239
205
  function getSourceToPermalink() {
240
- const allDocs = lodash_1.flatten(content.loadedVersions.map((v) => v.docs));
241
- return lodash_1.mapValues(lodash_1.keyBy(allDocs, (d) => d.source), (d) => d.permalink);
206
+ const allDocs = content.loadedVersions.flatMap((v) => v.docs);
207
+ return (0, lodash_1.mapValues)((0, lodash_1.keyBy)(allDocs, (d) => d.source), (d) => d.permalink);
242
208
  }
243
209
  const docsMarkdownOptions = {
244
210
  siteDir,
@@ -248,16 +214,17 @@ function pluginContentDocs(context, options) {
248
214
  if (siteConfig.onBrokenMarkdownLinks === 'ignore') {
249
215
  return;
250
216
  }
251
- utils_1.reportMessage(`Docs markdown link couldn't be resolved: (${brokenMarkdownLink.link}) in ${brokenMarkdownLink.filePath} for version ${brokenMarkdownLink.contentPaths.versionName}`, siteConfig.onBrokenMarkdownLinks);
217
+ (0, utils_1.reportMessage)(`Docs markdown link couldn't be resolved: (${brokenMarkdownLink.link}) in ${brokenMarkdownLink.filePath} for version ${brokenMarkdownLink.contentPaths.versionName}`, siteConfig.onBrokenMarkdownLinks);
252
218
  },
253
219
  };
254
220
  function createMDXLoaderRule() {
221
+ const contentDirs = versionsMetadata.flatMap(versions_1.getDocsDirPaths);
255
222
  return {
256
223
  test: /(\.mdx?)$/,
257
- include: lodash_1.flatten(versionsMetadata.map(versions_1.getDocsDirPaths))
224
+ include: contentDirs
258
225
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
259
226
  .map(utils_1.addTrailingPathSeparator),
260
- use: lodash_1.compact([
227
+ use: [
261
228
  getJSLoader({ isServer }),
262
229
  {
263
230
  loader: require.resolve('@docusaurus/mdx-loader'),
@@ -266,12 +233,14 @@ function pluginContentDocs(context, options) {
266
233
  rehypePlugins,
267
234
  beforeDefaultRehypePlugins,
268
235
  beforeDefaultRemarkPlugins,
269
- staticDir: path_1.default.join(siteDir, constants_1.STATIC_DIR_NAME),
236
+ staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
237
+ siteDir,
238
+ isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
270
239
  metadataPath: (mdxPath) => {
271
240
  // Note that metadataPath must be the same/in-sync as
272
241
  // the path from createData for each MDX.
273
- const aliasedPath = utils_1.aliasedSitePath(mdxPath, siteDir);
274
- return path_1.default.join(dataDir, `${utils_1.docuHash(aliasedPath)}.json`);
242
+ const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
243
+ return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
275
244
  },
276
245
  },
277
246
  },
@@ -279,14 +248,14 @@ function pluginContentDocs(context, options) {
279
248
  loader: path_1.default.resolve(__dirname, './markdown/index.js'),
280
249
  options: docsMarkdownOptions,
281
250
  },
282
- ]),
251
+ ].filter(Boolean),
283
252
  };
284
253
  }
285
254
  return {
286
255
  ignoreWarnings: [
287
256
  // Suppress warnings about non-existing of versions file.
288
257
  (e) => e.message.includes("Can't resolve") &&
289
- e.message.includes(constants_2.VERSIONS_JSON_FILE),
258
+ e.message.includes(constants_1.VERSIONS_JSON_FILE),
290
259
  ],
291
260
  resolve: {
292
261
  alias: {
package/lib/lastUpdate.js CHANGED
@@ -8,10 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getFileLastUpdate = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
12
- const execa_1 = tslib_1.__importDefault(require("execa"));
13
- const path_1 = tslib_1.__importDefault(require("path"));
14
- const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+), (.+)$/;
11
+ const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
+ const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),(.+)$/;
15
14
  let showedGitRequirementError = false;
16
15
  async function getFileLastUpdate(filePath) {
17
16
  if (!filePath) {
@@ -32,19 +31,20 @@ async function getFileLastUpdate(filePath) {
32
31
  if (!shelljs_1.default.which('git')) {
33
32
  if (!showedGitRequirementError) {
34
33
  showedGitRequirementError = true;
35
- 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.');
36
35
  }
37
36
  return null;
38
37
  }
39
- const fileBasename = path_1.default.basename(filePath);
40
- const fileDirname = path_1.default.dirname(filePath);
41
- const { stdout } = await execa_1.default('git', ['log', '-1', '--format=%ct, %an', fileBasename], {
42
- cwd: fileDirname,
38
+ const result = shelljs_1.default.exec(`git log -1 --format=%ct,%an ${filePath}`, {
39
+ silent: true,
43
40
  });
44
- return getTimestampAndAuthor(stdout);
41
+ if (result.code !== 0) {
42
+ throw new Error(`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`);
43
+ }
44
+ return getTimestampAndAuthor(result.stdout.trim());
45
45
  }
46
- catch (error) {
47
- console.error(error);
46
+ catch (e) {
47
+ logger_1.default.error(e);
48
48
  }
49
49
  return null;
50
50
  }
@@ -4,9 +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
- /// <reference types="node" />
8
- interface Loader extends Function {
9
- (this: any, source: string): string | Buffer | void | undefined;
10
- }
11
- declare const markdownLoader: Loader;
12
- export default markdownLoader;
7
+ import { DocsMarkdownOption } from '../types';
8
+ import type { LoaderContext } from 'webpack';
9
+ export default function markdownLoader(this: LoaderContext<DocsMarkdownOption>, source: string): void;
@@ -7,10 +7,10 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const linkify_1 = require("./linkify");
10
- const markdownLoader = function (source) {
10
+ function markdownLoader(source) {
11
11
  const fileString = source;
12
12
  const callback = this.async();
13
13
  const options = this.getOptions();
14
- return (callback && callback(null, linkify_1.linkify(fileString, this.resourcePath, options)));
15
- };
14
+ return (callback && callback(null, (0, linkify_1.linkify)(fileString, this.resourcePath, options)));
15
+ }
16
16
  exports.default = markdownLoader;
@@ -10,7 +10,7 @@ exports.linkify = void 0;
10
10
  const versions_1 = require("../versions");
11
11
  const utils_1 = require("@docusaurus/utils");
12
12
  function getVersion(filePath, options) {
13
- const versionFound = options.versionsMetadata.find((version) => versions_1.getDocsDirPaths(version).some((docsDirPath) => filePath.startsWith(docsDirPath)));
13
+ const versionFound = options.versionsMetadata.find((version) => (0, versions_1.getDocsDirPaths)(version).some((docsDirPath) => filePath.startsWith(docsDirPath)));
14
14
  if (!versionFound) {
15
15
  throw new Error(`Unexpected error: Markdown file at "${filePath}" does not belong to any docs version!`);
16
16
  }
@@ -18,7 +18,7 @@ function getVersion(filePath, options) {
18
18
  }
19
19
  function linkify(fileString, filePath, options) {
20
20
  const { siteDir, sourceToPermalink, onBrokenMarkdownLink } = options;
21
- const { newContent, brokenMarkdownLinks } = utils_1.replaceMarkdownLinks({
21
+ const { newContent, brokenMarkdownLinks } = (0, utils_1.replaceMarkdownLinks)({
22
22
  siteDir,
23
23
  fileString,
24
24
  filePath,
@@ -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 { NumberPrefixParser } from './types';
7
+ import type { NumberPrefixParser } from './types';
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,9 +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 { PluginOptions } from './types';
7
+ import type { PluginOptions } from './types';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
- import { OptionValidationContext, ValidationResult } from '@docusaurus/types';
9
+ import type { OptionValidationContext, ValidationResult } from '@docusaurus/types';
10
10
  export declare const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'>;
11
11
  export declare const OptionsSchema: Joi.ObjectSchema<any>;
12
- export declare function validateOptions({ validate, options, }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions>;
12
+ export declare function validateOptions({ validate, options: userOptions, }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions>;
package/lib/options.js CHANGED
@@ -1,21 +1,32 @@
1
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
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.validateOptions = exports.OptionsSchema = exports.DEFAULT_OPTIONS = void 0;
4
10
  const tslib_1 = require("tslib");
5
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
8
- const sidebarItemsGenerator_1 = require("./sidebarItemsGenerator");
12
+ const utils_1 = require("@docusaurus/utils");
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
+ const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admonitions"));
15
+ const generator_1 = require("./sidebars/generator");
9
16
  const numberPrefix_1 = require("./numberPrefix");
10
17
  exports.DEFAULT_OPTIONS = {
11
18
  path: 'docs',
12
19
  routeBasePath: 'docs',
13
- homePageId: undefined,
20
+ tagsBasePath: 'tags',
14
21
  include: ['**/*.{md,mdx}'],
15
- sidebarItemsGenerator: sidebarItemsGenerator_1.DefaultSidebarItemsGenerator,
22
+ exclude: utils_1.GlobExcludeDefault,
23
+ sidebarItemsGenerator: generator_1.DefaultSidebarItemsGenerator,
16
24
  numberPrefixParser: numberPrefix_1.DefaultNumberPrefixParser,
17
25
  docLayoutComponent: '@theme/DocPage',
18
26
  docItemComponent: '@theme/DocItem',
27
+ docTagDocListComponent: '@theme/DocTagDocListPage',
28
+ docTagsListComponent: '@theme/DocTagsListPage',
29
+ docCategoryGeneratedIndexComponent: '@theme/DocCategoryGeneratedIndexPage',
19
30
  remarkPlugins: [],
20
31
  rehypePlugins: [],
21
32
  beforeDefaultRemarkPlugins: [],
@@ -29,11 +40,15 @@ exports.DEFAULT_OPTIONS = {
29
40
  versions: {},
30
41
  editCurrentVersion: false,
31
42
  editLocalizedFiles: false,
43
+ sidebarCollapsible: true,
44
+ sidebarCollapsed: true,
32
45
  };
33
46
  const VersionOptionsSchema = utils_validation_1.Joi.object({
34
47
  path: utils_validation_1.Joi.string().allow('').optional(),
35
48
  label: utils_validation_1.Joi.string().optional(),
36
49
  banner: utils_validation_1.Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
50
+ badge: utils_validation_1.Joi.boolean().optional(),
51
+ className: utils_validation_1.Joi.string().optional(),
37
52
  });
38
53
  const VersionsOptionsSchema = utils_validation_1.Joi.object()
39
54
  .pattern(utils_validation_1.Joi.string().required(), VersionOptionsSchema)
@@ -47,10 +62,16 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
47
62
  // '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
48
63
  // .allow('') ""
49
64
  .default(exports.DEFAULT_OPTIONS.routeBasePath),
50
- homePageId: utils_validation_1.Joi.string().optional(),
65
+ tagsBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.tagsBasePath),
66
+ homePageId: utils_validation_1.Joi.any().forbidden().messages({
67
+ 'any.unknown': 'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
68
+ }),
51
69
  include: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.include),
70
+ exclude: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()).default(exports.DEFAULT_OPTIONS.exclude),
52
71
  sidebarPath: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.boolean().invalid(true), utils_validation_1.Joi.string()),
53
72
  sidebarItemsGenerator: utils_validation_1.Joi.function().default(() => exports.DEFAULT_OPTIONS.sidebarItemsGenerator),
73
+ sidebarCollapsible: utils_validation_1.Joi.boolean().default(exports.DEFAULT_OPTIONS.sidebarCollapsible),
74
+ sidebarCollapsed: utils_validation_1.Joi.boolean().default(exports.DEFAULT_OPTIONS.sidebarCollapsed),
54
75
  numberPrefixParser: utils_validation_1.Joi.alternatives()
55
76
  .try(utils_validation_1.Joi.function(),
56
77
  // Convert boolean values to functions
@@ -60,6 +81,9 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
60
81
  .default(() => exports.DEFAULT_OPTIONS.numberPrefixParser),
61
82
  docLayoutComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docLayoutComponent),
62
83
  docItemComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docItemComponent),
84
+ docTagsListComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docTagsListComponent),
85
+ docTagDocListComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docTagDocListComponent),
86
+ docCategoryGeneratedIndexComponent: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.docCategoryGeneratedIndexComponent),
63
87
  remarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.remarkPlugins),
64
88
  rehypePlugins: utils_validation_1.RehypePluginsSchema.default(exports.DEFAULT_OPTIONS.rehypePlugins),
65
89
  beforeDefaultRemarkPlugins: utils_validation_1.RemarkPluginsSchema.default(exports.DEFAULT_OPTIONS.beforeDefaultRemarkPlugins),
@@ -75,11 +99,24 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
75
99
  lastVersion: utils_validation_1.Joi.string().optional(),
76
100
  versions: VersionsOptionsSchema,
77
101
  });
78
- function validateOptions({ validate, options, }) {
79
- // TODO remove homePageId before end of 2020
80
- // "slug: /" is better because the home doc can be different across versions
81
- if (options.homePageId) {
82
- console.log(chalk_1.default.red(`The docs plugin option homePageId=${options.homePageId} is deprecated. To make a doc the "home", prefer frontmatter: "slug: /"`));
102
+ function validateOptions({ validate, options: userOptions, }) {
103
+ let options = userOptions;
104
+ if (options.sidebarCollapsible === false) {
105
+ // When sidebarCollapsible=false and sidebarCollapsed=undefined, we don't want to have the inconsistency warning
106
+ // We let options.sidebarCollapsible become the default value for options.sidebarCollapsed
107
+ if (typeof options.sidebarCollapsed === 'undefined') {
108
+ options = {
109
+ ...options,
110
+ sidebarCollapsed: false,
111
+ };
112
+ }
113
+ if (options.sidebarCollapsed) {
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
+ options = {
116
+ ...options,
117
+ sidebarCollapsed: false,
118
+ };
119
+ }
83
120
  }
84
121
  const normalizedOptions = validate(exports.OptionsSchema, options);
85
122
  if (normalizedOptions.admonitions) {
package/lib/props.d.ts CHANGED
@@ -4,7 +4,12 @@
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 { LoadedVersion } from './types';
8
- import { PropSidebars, PropVersionMetadata } from '@docusaurus/plugin-content-docs-types';
7
+ import type { LoadedVersion, VersionTag, DocMetadata } from './types';
8
+ import type { PropSidebars, PropVersionMetadata, PropTagDocList } from '@docusaurus/plugin-content-docs';
9
9
  export declare function toSidebarsProp(loadedVersion: LoadedVersion): PropSidebars;
10
10
  export declare function toVersionMetadataProp(pluginId: string, loadedVersion: LoadedVersion): PropVersionMetadata;
11
+ export declare function toTagDocListProp({ allTagsPath, tag, docs, }: {
12
+ allTagsPath: string;
13
+ tag: VersionTag;
14
+ docs: Pick<DocMetadata, 'id' | 'title' | 'description' | 'permalink'>[];
15
+ }): PropTagDocList;