@docusaurus/plugin-content-docs 0.0.0-6068 → 0.0.0-6069

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 (3) hide show
  1. package/lib/index.js +38 -35
  2. package/package.json +11 -11
  3. package/src/index.ts +50 -47
package/lib/index.js CHANGED
@@ -47,42 +47,45 @@ async function pluginContentDocs(context, options) {
47
47
  .flatMap(utils_1.getContentPathList)
48
48
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
49
49
  .map(utils_1.addTrailingPathSeparator);
50
- const loaderOptions = {
51
- admonitions: options.admonitions,
52
- remarkPlugins,
53
- rehypePlugins,
54
- recmaPlugins,
55
- beforeDefaultRehypePlugins,
56
- beforeDefaultRemarkPlugins,
57
- staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
58
- siteDir,
59
- isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
60
- metadataPath: (mdxPath) => {
61
- // Note that metadataPath must be the same/in-sync as
62
- // the path from createData for each MDX.
63
- const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
64
- return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
65
- },
66
- // createAssets converts relative paths to require() calls
67
- createAssets: ({ frontMatter }) => ({
68
- image: frontMatter.image,
69
- }),
70
- markdownConfig: siteConfig.markdown,
71
- resolveMarkdownLink: ({ linkPathname, sourceFilePath }) => {
72
- const version = (0, versions_1.getVersionFromSourceFilePath)(sourceFilePath, versionsMetadata);
73
- const permalink = (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
74
- sourceFilePath,
75
- sourceToPermalink: contentHelpers.sourceToPermalink,
76
- siteDir,
77
- contentPaths: version,
78
- });
79
- if (permalink === null) {
80
- logger_1.default.report(siteConfig.onBrokenMarkdownLinks) `Docs markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath} for version number=${version.versionName}`;
81
- }
82
- return permalink;
50
+ return (0, mdx_loader_1.createMDXLoaderRule)({
51
+ include: contentDirs,
52
+ options: {
53
+ useCrossCompilerCache: siteConfig.future.experimental_faster.mdxCrossCompilerCache,
54
+ admonitions: options.admonitions,
55
+ remarkPlugins,
56
+ rehypePlugins,
57
+ recmaPlugins,
58
+ beforeDefaultRehypePlugins,
59
+ beforeDefaultRemarkPlugins,
60
+ staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
61
+ siteDir,
62
+ isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
63
+ metadataPath: (mdxPath) => {
64
+ // Note that metadataPath must be the same/in-sync as
65
+ // the path from createData for each MDX.
66
+ const aliasedPath = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
67
+ return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedPath)}.json`);
68
+ },
69
+ // createAssets converts relative paths to require() calls
70
+ createAssets: ({ frontMatter }) => ({
71
+ image: frontMatter.image,
72
+ }),
73
+ markdownConfig: siteConfig.markdown,
74
+ resolveMarkdownLink: ({ linkPathname, sourceFilePath }) => {
75
+ const version = (0, versions_1.getVersionFromSourceFilePath)(sourceFilePath, versionsMetadata);
76
+ const permalink = (0, utils_1.resolveMarkdownLinkPathname)(linkPathname, {
77
+ sourceFilePath,
78
+ sourceToPermalink: contentHelpers.sourceToPermalink,
79
+ siteDir,
80
+ contentPaths: version,
81
+ });
82
+ if (permalink === null) {
83
+ logger_1.default.report(siteConfig.onBrokenMarkdownLinks) `Docs markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath} for version number=${version.versionName}`;
84
+ }
85
+ return permalink;
86
+ },
83
87
  },
84
- };
85
- return (0, mdx_loader_1.createMDXLoaderRule)({ include: contentDirs, options: loaderOptions });
88
+ });
86
89
  }
87
90
  const docsMDXLoaderRule = await createDocsMDXLoaderRule();
88
91
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-6068",
3
+ "version": "0.0.0-6069",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@docusaurus/core": "0.0.0-6068",
39
- "@docusaurus/logger": "0.0.0-6068",
40
- "@docusaurus/mdx-loader": "0.0.0-6068",
41
- "@docusaurus/module-type-aliases": "0.0.0-6068",
42
- "@docusaurus/theme-common": "0.0.0-6068",
43
- "@docusaurus/types": "0.0.0-6068",
44
- "@docusaurus/utils": "0.0.0-6068",
45
- "@docusaurus/utils-common": "0.0.0-6068",
46
- "@docusaurus/utils-validation": "0.0.0-6068",
38
+ "@docusaurus/core": "0.0.0-6069",
39
+ "@docusaurus/logger": "0.0.0-6069",
40
+ "@docusaurus/mdx-loader": "0.0.0-6069",
41
+ "@docusaurus/module-type-aliases": "0.0.0-6069",
42
+ "@docusaurus/theme-common": "0.0.0-6069",
43
+ "@docusaurus/types": "0.0.0-6069",
44
+ "@docusaurus/utils": "0.0.0-6069",
45
+ "@docusaurus/utils-common": "0.0.0-6069",
46
+ "@docusaurus/utils-validation": "0.0.0-6069",
47
47
  "@types/react-router-config": "^5.0.7",
48
48
  "combine-promises": "^1.1.0",
49
49
  "fs-extra": "^11.1.1",
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=18.0"
69
69
  },
70
- "gitHead": "4f0bc982b589965d7238334bb9b5bf6c483cc35a"
70
+ "gitHead": "7258877748d2a7c1682c5c92dae3a17734a7e59e"
71
71
  }
package/src/index.ts CHANGED
@@ -25,10 +25,7 @@ import {
25
25
  getTagsFile,
26
26
  getTagsFilePathsToWatch,
27
27
  } from '@docusaurus/utils-validation';
28
- import {
29
- createMDXLoaderRule,
30
- type Options as MDXLoaderOptions,
31
- } from '@docusaurus/mdx-loader';
28
+ import {createMDXLoaderRule} from '@docusaurus/mdx-loader';
32
29
  import {loadSidebars, resolveSidebarPathOption} from './sidebars';
33
30
  import {CategoryMetadataFilenamePattern} from './sidebars/generator';
34
31
  import {
@@ -107,50 +104,56 @@ export default async function pluginContentDocs(
107
104
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
108
105
  .map(addTrailingPathSeparator);
109
106
 
110
- const loaderOptions: MDXLoaderOptions = {
111
- admonitions: options.admonitions,
112
- remarkPlugins,
113
- rehypePlugins,
114
- recmaPlugins,
115
- beforeDefaultRehypePlugins,
116
- beforeDefaultRemarkPlugins,
117
- staticDirs: siteConfig.staticDirectories.map((dir) =>
118
- path.resolve(siteDir, dir),
119
- ),
120
- siteDir,
121
- isMDXPartial: createAbsoluteFilePathMatcher(options.exclude, contentDirs),
122
- metadataPath: (mdxPath: string) => {
123
- // Note that metadataPath must be the same/in-sync as
124
- // the path from createData for each MDX.
125
- const aliasedPath = aliasedSitePath(mdxPath, siteDir);
126
- return path.join(dataDir, `${docuHash(aliasedPath)}.json`);
127
- },
128
- // createAssets converts relative paths to require() calls
129
- createAssets: ({frontMatter}: {frontMatter: DocFrontMatter}) => ({
130
- image: frontMatter.image,
131
- }),
132
- markdownConfig: siteConfig.markdown,
133
- resolveMarkdownLink: ({linkPathname, sourceFilePath}) => {
134
- const version = getVersionFromSourceFilePath(
135
- sourceFilePath,
136
- versionsMetadata,
137
- );
138
- const permalink = resolveMarkdownLinkPathname(linkPathname, {
139
- sourceFilePath,
140
- sourceToPermalink: contentHelpers.sourceToPermalink,
141
- siteDir,
142
- contentPaths: version,
143
- });
144
- if (permalink === null) {
145
- logger.report(
146
- siteConfig.onBrokenMarkdownLinks,
147
- )`Docs markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath} for version number=${version.versionName}`;
148
- }
149
- return permalink;
107
+ return createMDXLoaderRule({
108
+ include: contentDirs,
109
+ options: {
110
+ useCrossCompilerCache:
111
+ siteConfig.future.experimental_faster.mdxCrossCompilerCache,
112
+ admonitions: options.admonitions,
113
+ remarkPlugins,
114
+ rehypePlugins,
115
+ recmaPlugins,
116
+ beforeDefaultRehypePlugins,
117
+ beforeDefaultRemarkPlugins,
118
+ staticDirs: siteConfig.staticDirectories.map((dir) =>
119
+ path.resolve(siteDir, dir),
120
+ ),
121
+ siteDir,
122
+ isMDXPartial: createAbsoluteFilePathMatcher(
123
+ options.exclude,
124
+ contentDirs,
125
+ ),
126
+ metadataPath: (mdxPath: string) => {
127
+ // Note that metadataPath must be the same/in-sync as
128
+ // the path from createData for each MDX.
129
+ const aliasedPath = aliasedSitePath(mdxPath, siteDir);
130
+ return path.join(dataDir, `${docuHash(aliasedPath)}.json`);
131
+ },
132
+ // createAssets converts relative paths to require() calls
133
+ createAssets: ({frontMatter}: {frontMatter: DocFrontMatter}) => ({
134
+ image: frontMatter.image,
135
+ }),
136
+ markdownConfig: siteConfig.markdown,
137
+ resolveMarkdownLink: ({linkPathname, sourceFilePath}) => {
138
+ const version = getVersionFromSourceFilePath(
139
+ sourceFilePath,
140
+ versionsMetadata,
141
+ );
142
+ const permalink = resolveMarkdownLinkPathname(linkPathname, {
143
+ sourceFilePath,
144
+ sourceToPermalink: contentHelpers.sourceToPermalink,
145
+ siteDir,
146
+ contentPaths: version,
147
+ });
148
+ if (permalink === null) {
149
+ logger.report(
150
+ siteConfig.onBrokenMarkdownLinks,
151
+ )`Docs markdown link couldn't be resolved: (url=${linkPathname}) in source file path=${sourceFilePath} for version number=${version.versionName}`;
152
+ }
153
+ return permalink;
154
+ },
150
155
  },
151
- };
152
-
153
- return createMDXLoaderRule({include: contentDirs, options: loaderOptions});
156
+ });
154
157
  }
155
158
 
156
159
  const docsMDXLoaderRule = await createDocsMDXLoaderRule();