@docusaurus/plugin-content-docs 0.0.0-4788 → 0.0.0-4792

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4788",
3
+ "version": "0.0.0-4792",
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-4788",
27
- "@docusaurus/logger": "0.0.0-4788",
28
- "@docusaurus/mdx-loader": "0.0.0-4788",
29
- "@docusaurus/utils": "0.0.0-4788",
30
- "@docusaurus/utils-validation": "0.0.0-4788",
26
+ "@docusaurus/core": "0.0.0-4792",
27
+ "@docusaurus/logger": "0.0.0-4792",
28
+ "@docusaurus/mdx-loader": "0.0.0-4792",
29
+ "@docusaurus/utils": "0.0.0-4792",
30
+ "@docusaurus/utils-validation": "0.0.0-4792",
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-4788",
43
- "@docusaurus/types": "0.0.0-4788",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4792",
43
+ "@docusaurus/types": "0.0.0-4792",
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": "880b995e4b33e050d1e6cb2bcbe5058ee6fd8cbd"
59
+ "gitHead": "38eb1dcf25728a582b37f71e41ad5d21cc17db1f"
60
60
  }
@@ -5,7 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {CategoryGeneratedIndexMetadata, DocMetadataBase} from './types';
8
+ import type {
9
+ CategoryGeneratedIndexMetadata,
10
+ DocMetadataBase,
11
+ } from '@docusaurus/plugin-content-docs';
9
12
  import type {SidebarItemCategoryWithGeneratedIndex} from './sidebars/types';
10
13
  import {type SidebarsUtils, toNavigationLink} from './sidebars/utils';
11
14
  import {createDocsByIdIndex} from './docs';
@@ -29,8 +32,10 @@ function getCategoryGeneratedIndexMetadata({
29
32
  slug: category.link.slug,
30
33
  permalink: category.link.permalink,
31
34
  sidebar: sidebarName!,
32
- previous: toNavigationLink(previous, docsById),
33
- next: toNavigationLink(next, docsById),
35
+ navigation: {
36
+ previous: toNavigationLink(previous, docsById),
37
+ next: toNavigationLink(next, docsById),
38
+ },
34
39
  };
35
40
  }
36
41
 
package/src/docs.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  aliasedSitePath,
13
13
  getEditUrl,
14
14
  getFolderContainingFile,
15
+ getContentPathList,
15
16
  normalizeUrl,
16
17
  parseMarkdownString,
17
18
  posixPath,
@@ -21,18 +22,9 @@ import {
21
22
  import type {LoadContext} from '@docusaurus/types';
22
23
 
23
24
  import {getFileLastUpdate} from './lastUpdate';
24
- import type {
25
- DocFile,
26
- DocMetadataBase,
27
- DocMetadata,
28
- DocNavLink,
29
- LastUpdateData,
30
- VersionMetadata,
31
- LoadedVersion,
32
- } from './types';
25
+ import type {DocFile, LoadedVersion} from './types';
33
26
  import getSlug from './slug';
34
27
  import {CURRENT_VERSION_NAME} from './constants';
35
- import {getDocsDirPaths} from './versions';
36
28
  import {stripPathNumberPrefixes} from './numberPrefix';
37
29
  import {validateDocFrontMatter} from './frontMatter';
38
30
  import type {SidebarsUtils} from './sidebars/utils';
@@ -41,7 +33,11 @@ import type {
41
33
  MetadataOptions,
42
34
  PluginOptions,
43
35
  CategoryIndexMatcher,
44
- CategoryIndexMatcherParam,
36
+ DocMetadataBase,
37
+ DocMetadata,
38
+ PropNavigationLink,
39
+ LastUpdateData,
40
+ VersionMetadata,
45
41
  } from '@docusaurus/plugin-content-docs';
46
42
 
47
43
  type LastUpdateOptions = Pick<
@@ -85,7 +81,7 @@ export async function readDocFile(
85
81
  options: LastUpdateOptions,
86
82
  ): Promise<DocFile> {
87
83
  const contentPath = await getFolderContainingFile(
88
- getDocsDirPaths(versionMetadata),
84
+ getContentPathList(versionMetadata),
89
85
  source,
90
86
  );
91
87
 
@@ -213,7 +209,7 @@ function doProcessDocMetadata({
213
209
 
214
210
  const description: string = frontMatter.description ?? excerpt ?? '';
215
211
 
216
- const permalink = normalizeUrl([versionMetadata.versionPath, docSlug]);
212
+ const permalink = normalizeUrl([versionMetadata.path, docSlug]);
217
213
 
218
214
  function getDocEditUrl() {
219
215
  const relativeFilePath = path.relative(contentPath, filePath);
@@ -232,8 +228,8 @@ function doProcessDocMetadata({
232
228
  const isLocalized = contentPath === versionMetadata.contentPathLocalized;
233
229
  const baseVersionEditUrl =
234
230
  isLocalized && options.editLocalizedFiles
235
- ? versionMetadata.versionEditUrlLocalized
236
- : versionMetadata.versionEditUrl;
231
+ ? versionMetadata.editUrlLocalized
232
+ : versionMetadata.editUrl;
237
233
  return getEditUrl(relativeFilePath, baseVersionEditUrl);
238
234
  }
239
235
  return undefined;
@@ -304,7 +300,7 @@ export function addDocNavigation(
304
300
  const toNavigationLinkByDocId = (
305
301
  docId: string | null | undefined,
306
302
  type: 'prev' | 'next',
307
- ): DocNavLink | undefined => {
303
+ ): PropNavigationLink | undefined => {
308
304
  if (!docId) {
309
305
  return undefined;
310
306
  }
@@ -401,7 +397,7 @@ export function toCategoryIndexMatcherParam({
401
397
  }: Pick<
402
398
  DocMetadataBase,
403
399
  'source' | 'sourceDirName'
404
- >): CategoryIndexMatcherParam {
400
+ >): Parameters<CategoryIndexMatcher>[0] {
405
401
  // source + sourceDirName are always posix-style
406
402
  return {
407
403
  fileName: path.posix.parse(source).name,
@@ -12,7 +12,7 @@ import {
12
12
  FrontMatterTOCHeadingLevels,
13
13
  validateFrontMatter,
14
14
  } from '@docusaurus/utils-validation';
15
- import type {DocFrontMatter} from './types';
15
+ import type {DocFrontMatter} from '@docusaurus/plugin-content-docs';
16
16
 
17
17
  // NOTE: we don't add any default value on purpose here
18
18
  // We don't want default values to magically appear in doc metadata and props
package/src/globalData.ts CHANGED
@@ -8,11 +8,11 @@
8
8
  import _ from 'lodash';
9
9
  import type {Sidebars} from './sidebars/types';
10
10
  import {createSidebarsUtils} from './sidebars/utils';
11
+ import type {LoadedVersion} from './types';
11
12
  import type {
12
13
  CategoryGeneratedIndexMetadata,
13
14
  DocMetadata,
14
- LoadedVersion,
15
- } from './types';
15
+ } from '@docusaurus/plugin-content-docs';
16
16
  import type {
17
17
  GlobalVersion,
18
18
  GlobalSidebar,
@@ -65,9 +65,9 @@ function toGlobalSidebars(
65
65
  export function toGlobalDataVersion(version: LoadedVersion): GlobalVersion {
66
66
  return {
67
67
  name: version.versionName,
68
- label: version.versionLabel,
68
+ label: version.label,
69
69
  isLast: version.isLast,
70
- path: version.versionPath,
70
+ path: version.path,
71
71
  mainDocId: version.mainDocId,
72
72
  docs: version.docs
73
73
  .map(toGlobalDataDoc)
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  normalizeUrl,
12
12
  docuHash,
13
13
  aliasedSitePath,
14
+ getContentPathList,
14
15
  reportMessage,
15
16
  posixPath,
16
17
  addTrailingPathSeparator,
@@ -27,18 +28,14 @@ import {
27
28
  addDocNavigation,
28
29
  getMainDocId,
29
30
  } from './docs';
30
- import {getDocsDirPaths, readVersionsMetadata} from './versions';
31
-
31
+ import {readVersionsMetadata} from './versions';
32
32
  import type {
33
33
  LoadedContent,
34
34
  SourceToPermalink,
35
- DocMetadataBase,
36
- VersionMetadata,
37
35
  LoadedVersion,
38
36
  DocFile,
39
37
  DocsMarkdownOption,
40
38
  VersionTag,
41
- DocFrontMatter,
42
39
  } from './types';
43
40
  import type {RuleSetRule} from 'webpack';
44
41
  import {cliDocsVersionCommand} from './cli';
@@ -55,6 +52,9 @@ import {createVersionRoutes} from './routes';
55
52
  import type {
56
53
  PropTagsListPage,
57
54
  PluginOptions,
55
+ DocMetadataBase,
56
+ VersionMetadata,
57
+ DocFrontMatter,
58
58
  } from '@docusaurus/plugin-content-docs';
59
59
  import {createSidebarsUtils} from './sidebars/utils';
60
60
  import {getCategoryGeneratedIndexMetadataList} from './categoryGeneratedIndex';
@@ -114,7 +114,7 @@ export default async function pluginContentDocs(
114
114
  function getVersionPathsToWatch(version: VersionMetadata): string[] {
115
115
  const result = [
116
116
  ...options.include.flatMap((pattern) =>
117
- getDocsDirPaths(version).map(
117
+ getContentPathList(version).map(
118
118
  (docsDirPath) => `${docsDirPath}/${pattern}`,
119
119
  ),
120
120
  ),
@@ -228,7 +228,7 @@ export default async function pluginContentDocs(
228
228
  const tagsProp: PropTagsListPage['tags'] = Object.values(
229
229
  versionTags,
230
230
  ).map((tagValue) => ({
231
- name: tagValue.name,
231
+ name: tagValue.label,
232
232
  permalink: tagValue.permalink,
233
233
  count: tagValue.docIds.length,
234
234
  }));
@@ -331,7 +331,7 @@ export default async function pluginContentDocs(
331
331
  };
332
332
 
333
333
  function createMDXLoaderRule(): RuleSetRule {
334
- const contentDirs = versionsMetadata.flatMap(getDocsDirPaths);
334
+ const contentDirs = versionsMetadata.flatMap(getContentPathList);
335
335
  return {
336
336
  test: /\.mdx?$/i,
337
337
  include: contentDirs
@@ -6,12 +6,11 @@
6
6
  */
7
7
 
8
8
  import type {DocsMarkdownOption} from '../types';
9
- import {getDocsDirPaths} from '../versions';
10
- import {replaceMarkdownLinks} from '@docusaurus/utils';
9
+ import {replaceMarkdownLinks, getContentPathList} from '@docusaurus/utils';
11
10
 
12
11
  function getVersion(filePath: string, options: DocsMarkdownOption) {
13
12
  const versionFound = options.versionsMetadata.find((version) =>
14
- getDocsDirPaths(version).some((docsDirPath) =>
13
+ getContentPathList(version).some((docsDirPath) =>
15
14
  filePath.startsWith(docsDirPath),
16
15
  ),
17
16
  );