@docusaurus/plugin-content-docs 3.3.2 → 3.5.0

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 (90) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +0 -1
  2. package/lib/categoryGeneratedIndex.js +1 -2
  3. package/lib/cli.d.ts +0 -1
  4. package/lib/cli.js +1 -2
  5. package/lib/client/doc.d.ts +29 -0
  6. package/lib/client/doc.js +47 -0
  7. package/lib/client/docSidebarItemsExpandedState.d.ts +30 -0
  8. package/lib/client/docSidebarItemsExpandedState.js +27 -0
  9. package/lib/client/docsClientUtils.js +16 -8
  10. package/lib/client/docsPreferredVersion.d.ts +29 -0
  11. package/lib/client/docsPreferredVersion.js +124 -0
  12. package/lib/client/docsSearch.d.ts +19 -0
  13. package/lib/client/docsSearch.js +39 -0
  14. package/lib/{markdown/linkify.d.ts → client/docsSearch.test.d.ts} +1 -2
  15. package/lib/client/docsSearch.test.js +12 -0
  16. package/lib/client/docsSidebar.d.ts +25 -0
  17. package/lib/client/docsSidebar.js +29 -0
  18. package/lib/client/docsUtils.d.ts +106 -0
  19. package/lib/client/docsUtils.js +273 -0
  20. package/lib/client/docsVersion.d.ts +19 -0
  21. package/lib/client/docsVersion.js +25 -0
  22. package/lib/client/index.d.ts +8 -0
  23. package/lib/client/index.js +8 -0
  24. package/lib/docs.d.ts +2 -1
  25. package/lib/docs.js +17 -10
  26. package/lib/frontMatter.d.ts +0 -1
  27. package/lib/frontMatter.js +2 -2
  28. package/lib/globalData.js +1 -2
  29. package/lib/index.d.ts +0 -1
  30. package/lib/index.js +85 -55
  31. package/lib/numberPrefix.d.ts +0 -1
  32. package/lib/numberPrefix.js +3 -3
  33. package/lib/options.d.ts +0 -1
  34. package/lib/options.js +13 -2
  35. package/lib/props.d.ts +0 -1
  36. package/lib/props.js +7 -6
  37. package/lib/routes.d.ts +0 -1
  38. package/lib/routes.js +23 -7
  39. package/lib/sidebars/generator.js +3 -0
  40. package/lib/sidebars/index.d.ts +0 -1
  41. package/lib/sidebars/index.js +4 -4
  42. package/lib/sidebars/normalization.js +2 -3
  43. package/lib/sidebars/postProcessor.js +1 -2
  44. package/lib/sidebars/processor.js +1 -2
  45. package/lib/sidebars/types.d.ts +1 -1
  46. package/lib/sidebars/utils.d.ts +0 -1
  47. package/lib/sidebars/utils.js +13 -14
  48. package/lib/sidebars/validation.js +3 -3
  49. package/lib/slug.d.ts +0 -1
  50. package/lib/slug.js +1 -1
  51. package/lib/translations.d.ts +0 -1
  52. package/lib/translations.js +2 -3
  53. package/lib/types.d.ts +3 -14
  54. package/lib/versions/files.d.ts +0 -1
  55. package/lib/versions/files.js +7 -8
  56. package/lib/versions/index.d.ts +1 -1
  57. package/lib/versions/index.js +15 -8
  58. package/lib/versions/validation.d.ts +0 -1
  59. package/lib/versions/validation.js +3 -4
  60. package/package.json +11 -10
  61. package/src/client/doc.tsx +71 -0
  62. package/src/client/docSidebarItemsExpandedState.tsx +55 -0
  63. package/src/client/docsClientUtils.ts +17 -8
  64. package/src/client/docsPreferredVersion.tsx +248 -0
  65. package/src/client/docsSearch.test.ts +14 -0
  66. package/src/client/docsSearch.ts +57 -0
  67. package/src/client/docsSidebar.tsx +50 -0
  68. package/src/client/docsUtils.tsx +415 -0
  69. package/src/client/docsVersion.tsx +36 -0
  70. package/src/client/index.ts +39 -0
  71. package/src/docs.ts +14 -2
  72. package/src/index.ts +116 -73
  73. package/src/options.ts +12 -0
  74. package/src/plugin-content-docs.d.ts +4 -3
  75. package/src/props.ts +2 -0
  76. package/src/routes.ts +23 -4
  77. package/src/sidebars/generator.ts +3 -0
  78. package/src/sidebars/postProcessor.ts +1 -0
  79. package/src/sidebars/types.ts +1 -0
  80. package/src/sidebars/validation.ts +1 -0
  81. package/src/types.ts +2 -16
  82. package/src/versions/index.ts +18 -1
  83. package/lib/markdown/index.d.ts +0 -9
  84. package/lib/markdown/index.js +0 -16
  85. package/lib/markdown/linkify.js +0 -34
  86. package/lib/tags.d.ts +0 -10
  87. package/lib/tags.js +0 -28
  88. package/src/markdown/index.ts +0 -20
  89. package/src/markdown/linkify.ts +0 -47
  90. package/src/tags.ts +0 -27
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {replaceMarkdownLinks, getContentPathList} from '@docusaurus/utils';
9
- import type {DocsMarkdownOption} from '../types';
10
-
11
- function getVersion(filePath: string, options: DocsMarkdownOption) {
12
- const versionFound = options.versionsMetadata.find((version) =>
13
- getContentPathList(version).some((docsDirPath) =>
14
- filePath.startsWith(docsDirPath),
15
- ),
16
- );
17
- // At this point, this should never happen, because the MDX loaders' paths are
18
- // literally using the version content paths; but if we allow sourcing content
19
- // from outside the docs directory (through the `include` option, for example;
20
- // is there a compelling use-case?), this would actually be testable
21
- if (!versionFound) {
22
- throw new Error(
23
- `Unexpected error: Markdown file at "${filePath}" does not belong to any docs version!`,
24
- );
25
- }
26
- return versionFound;
27
- }
28
-
29
- export function linkify(
30
- fileString: string,
31
- filePath: string,
32
- options: DocsMarkdownOption,
33
- ): string {
34
- const {siteDir, sourceToPermalink, onBrokenMarkdownLink} = options;
35
-
36
- const {newContent, brokenMarkdownLinks} = replaceMarkdownLinks({
37
- siteDir,
38
- fileString,
39
- filePath,
40
- contentPaths: getVersion(filePath, options),
41
- sourceToPermalink,
42
- });
43
-
44
- brokenMarkdownLinks.forEach((l) => onBrokenMarkdownLink(l));
45
-
46
- return newContent;
47
- }
package/src/tags.ts DELETED
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import _ from 'lodash';
9
- import {getTagVisibility, groupTaggedItems} from '@docusaurus/utils';
10
- import type {VersionTags} from './types';
11
- import type {DocMetadata} from '@docusaurus/plugin-content-docs';
12
-
13
- export function getVersionTags(docs: DocMetadata[]): VersionTags {
14
- const groups = groupTaggedItems(docs, (doc) => doc.tags);
15
- return _.mapValues(groups, ({tag, items: tagDocs}) => {
16
- const tagVisibility = getTagVisibility({
17
- items: tagDocs,
18
- isUnlisted: (item) => item.unlisted,
19
- });
20
- return {
21
- label: tag.label,
22
- docIds: tagVisibility.listedItems.map((item) => item.id),
23
- permalink: tag.permalink,
24
- unlisted: tagVisibility.unlisted,
25
- };
26
- });
27
- }