@docusaurus/plugin-content-docs 0.0.0-4721 → 0.0.0-4724

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.
@@ -11,6 +11,10 @@ const versions_1 = require("../versions");
11
11
  const utils_1 = require("@docusaurus/utils");
12
12
  function getVersion(filePath, options) {
13
13
  const versionFound = options.versionsMetadata.find((version) => (0, versions_1.getDocsDirPaths)(version).some((docsDirPath) => filePath.startsWith(docsDirPath)));
14
+ // At this point, this should never happen, because the MDX loaders' paths are
15
+ // literally using the version content paths; but if we allow sourcing content
16
+ // from outside the docs directory (through the `include` option, for example;
17
+ // is there a compelling use-case?), this would actually be testable
14
18
  if (!versionFound) {
15
19
  throw new Error(`Unexpected error: Markdown file at "${filePath}" does not belong to any docs version!`);
16
20
  }
@@ -39,22 +39,17 @@ function postProcessSidebarItem(item, params) {
39
39
  if (!category.link) {
40
40
  throw new Error(`Sidebar category ${item.label} has neither any subitem nor a link. This makes this item not able to link to anything.`);
41
41
  }
42
- switch (category.link.type) {
43
- case 'doc':
44
- return {
45
- type: 'doc',
46
- label: category.label,
47
- id: category.link.id,
48
- };
49
- case 'generated-index':
50
- return {
51
- type: 'link',
52
- label: category.label,
53
- href: category.link.permalink,
54
- };
55
- default:
56
- throw new Error('Unexpected sidebar category link type');
57
- }
42
+ return category.link.type === 'doc'
43
+ ? {
44
+ type: 'doc',
45
+ label: category.label,
46
+ id: category.link.id,
47
+ }
48
+ : {
49
+ type: 'link',
50
+ label: category.label,
51
+ href: category.link.permalink,
52
+ };
58
53
  }
59
54
  // A non-collapsible category can't be collapsed!
60
55
  if (category.collapsible === false) {
@@ -236,21 +236,14 @@ function toNavigationLink(navigationItem, docsById) {
236
236
  if (!navigationItem) {
237
237
  return undefined;
238
238
  }
239
- if (navigationItem.type === 'doc') {
240
- return toDocNavigationLink(getDocById(navigationItem.id));
241
- }
242
- else if (navigationItem.type === 'category') {
243
- if (navigationItem.link.type === 'doc') {
244
- return toDocNavigationLink(getDocById(navigationItem.link.id));
245
- }
246
- else if (navigationItem.link.type === 'generated-index') {
247
- return {
239
+ if (navigationItem.type === 'category') {
240
+ return navigationItem.link.type === 'doc'
241
+ ? toDocNavigationLink(getDocById(navigationItem.link.id))
242
+ : {
248
243
  title: navigationItem.label,
249
244
  permalink: navigationItem.link.permalink,
250
245
  };
251
- }
252
- throw new Error('unexpected category link type');
253
246
  }
254
- throw new Error('unexpected navigation item');
247
+ return toDocNavigationLink(getDocById(navigationItem.id));
255
248
  }
256
249
  exports.toNavigationLink = toNavigationLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4721",
3
+ "version": "0.0.0-4724",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4721",
27
- "@docusaurus/logger": "0.0.0-4721",
28
- "@docusaurus/mdx-loader": "0.0.0-4721",
29
- "@docusaurus/utils": "0.0.0-4721",
30
- "@docusaurus/utils-validation": "0.0.0-4721",
26
+ "@docusaurus/core": "0.0.0-4724",
27
+ "@docusaurus/logger": "0.0.0-4724",
28
+ "@docusaurus/mdx-loader": "0.0.0-4724",
29
+ "@docusaurus/utils": "0.0.0-4724",
30
+ "@docusaurus/utils-validation": "0.0.0-4724",
31
31
  "combine-promises": "^1.1.0",
32
32
  "fs-extra": "^10.0.1",
33
33
  "import-fresh": "^3.3.0",
@@ -39,8 +39,8 @@
39
39
  "webpack": "^5.70.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4721",
43
- "@docusaurus/types": "0.0.0-4721",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4724",
43
+ "@docusaurus/types": "0.0.0-4724",
44
44
  "@types/js-yaml": "^4.0.5",
45
45
  "@types/picomatch": "^2.3.0",
46
46
  "commander": "^5.1.0",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=14"
58
58
  },
59
- "gitHead": "e01ee5ebec6b6fd7e5084cc67014a555329cc336"
59
+ "gitHead": "4766d101935a9b634ac4670286aa0f51e35b75ae"
60
60
  }
@@ -15,6 +15,10 @@ function getVersion(filePath: string, options: DocsMarkdownOption) {
15
15
  filePath.startsWith(docsDirPath),
16
16
  ),
17
17
  );
18
+ // At this point, this should never happen, because the MDX loaders' paths are
19
+ // literally using the version content paths; but if we allow sourcing content
20
+ // from outside the docs directory (through the `include` option, for example;
21
+ // is there a compelling use-case?), this would actually be testable
18
22
  if (!versionFound) {
19
23
  throw new Error(
20
24
  `Unexpected error: Markdown file at "${filePath}" does not belong to any docs version!`,
@@ -58,22 +58,17 @@ function postProcessSidebarItem(
58
58
  `Sidebar category ${item.label} has neither any subitem nor a link. This makes this item not able to link to anything.`,
59
59
  );
60
60
  }
61
- switch (category.link.type) {
62
- case 'doc':
63
- return {
61
+ return category.link.type === 'doc'
62
+ ? {
64
63
  type: 'doc',
65
64
  label: category.label,
66
65
  id: category.link.id,
67
- };
68
- case 'generated-index':
69
- return {
66
+ }
67
+ : {
70
68
  type: 'link',
71
69
  label: category.label,
72
70
  href: category.link.permalink,
73
71
  };
74
- default:
75
- throw new Error('Unexpected sidebar category link type');
76
- }
77
72
  }
78
73
  // A non-collapsible category can't be collapsed!
79
74
  if (category.collapsible === false) {
@@ -376,18 +376,13 @@ export function toNavigationLink(
376
376
  return undefined;
377
377
  }
378
378
 
379
- if (navigationItem.type === 'doc') {
380
- return toDocNavigationLink(getDocById(navigationItem.id));
381
- } else if (navigationItem.type === 'category') {
382
- if (navigationItem.link.type === 'doc') {
383
- return toDocNavigationLink(getDocById(navigationItem.link.id));
384
- } else if (navigationItem.link.type === 'generated-index') {
385
- return {
386
- title: navigationItem.label,
387
- permalink: navigationItem.link.permalink,
388
- };
389
- }
390
- throw new Error('unexpected category link type');
379
+ if (navigationItem.type === 'category') {
380
+ return navigationItem.link.type === 'doc'
381
+ ? toDocNavigationLink(getDocById(navigationItem.link.id))
382
+ : {
383
+ title: navigationItem.label,
384
+ permalink: navigationItem.link.permalink,
385
+ };
391
386
  }
392
- throw new Error('unexpected navigation item');
387
+ return toDocNavigationLink(getDocById(navigationItem.id));
393
388
  }