@docusaurus/plugin-content-pages 3.3.1 → 3.4.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.
- package/lib/index.js +29 -34
- package/package.json +7 -7
- package/src/index.ts +39 -46
- package/lib/markdownLoader.d.ts +0 -8
- package/lib/markdownLoader.js +0 -16
- package/src/markdownLoader.ts +0 -22
package/lib/index.js
CHANGED
|
@@ -39,6 +39,34 @@ function pluginContentPages(context, options) {
|
|
|
39
39
|
configureWebpack() {
|
|
40
40
|
const { admonitions, rehypePlugins, remarkPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
|
|
41
41
|
const contentDirs = (0, content_1.getContentPathList)(contentPaths);
|
|
42
|
+
function createMDXLoader() {
|
|
43
|
+
const loaderOptions = {
|
|
44
|
+
admonitions,
|
|
45
|
+
remarkPlugins,
|
|
46
|
+
rehypePlugins,
|
|
47
|
+
beforeDefaultRehypePlugins,
|
|
48
|
+
beforeDefaultRemarkPlugins,
|
|
49
|
+
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
50
|
+
siteDir,
|
|
51
|
+
isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
|
|
52
|
+
metadataPath: (mdxPath) => {
|
|
53
|
+
// Note that metadataPath must be the same/in-sync as
|
|
54
|
+
// the path from createData for each MDX.
|
|
55
|
+
const aliasedSource = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
|
|
56
|
+
return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedSource)}.json`);
|
|
57
|
+
},
|
|
58
|
+
// Assets allow to convert some relative images paths to
|
|
59
|
+
// require(...) calls
|
|
60
|
+
createAssets: ({ frontMatter }) => ({
|
|
61
|
+
image: frontMatter.image,
|
|
62
|
+
}),
|
|
63
|
+
markdownConfig: siteConfig.markdown,
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
67
|
+
options: loaderOptions,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
42
70
|
return {
|
|
43
71
|
module: {
|
|
44
72
|
rules: [
|
|
@@ -47,40 +75,7 @@ function pluginContentPages(context, options) {
|
|
|
47
75
|
include: contentDirs
|
|
48
76
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
49
77
|
.map(utils_1.addTrailingPathSeparator),
|
|
50
|
-
use: [
|
|
51
|
-
{
|
|
52
|
-
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
53
|
-
options: {
|
|
54
|
-
admonitions,
|
|
55
|
-
remarkPlugins,
|
|
56
|
-
rehypePlugins,
|
|
57
|
-
beforeDefaultRehypePlugins,
|
|
58
|
-
beforeDefaultRemarkPlugins,
|
|
59
|
-
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
60
|
-
siteDir,
|
|
61
|
-
isMDXPartial: (0, utils_1.createAbsoluteFilePathMatcher)(options.exclude, contentDirs),
|
|
62
|
-
metadataPath: (mdxPath) => {
|
|
63
|
-
// Note that metadataPath must be the same/in-sync as
|
|
64
|
-
// the path from createData for each MDX.
|
|
65
|
-
const aliasedSource = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
|
|
66
|
-
return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedSource)}.json`);
|
|
67
|
-
},
|
|
68
|
-
// Assets allow to convert some relative images paths to
|
|
69
|
-
// require(...) calls
|
|
70
|
-
createAssets: ({ frontMatter, }) => ({
|
|
71
|
-
image: frontMatter.image,
|
|
72
|
-
}),
|
|
73
|
-
markdownConfig: siteConfig.markdown,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
loader: path_1.default.resolve(__dirname, './markdownLoader.js'),
|
|
78
|
-
options: {
|
|
79
|
-
// siteDir,
|
|
80
|
-
// contentPath,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
].filter(Boolean),
|
|
78
|
+
use: [createMDXLoader()],
|
|
84
79
|
},
|
|
85
80
|
],
|
|
86
81
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Pages plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-pages.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "3.
|
|
22
|
-
"@docusaurus/mdx-loader": "3.
|
|
23
|
-
"@docusaurus/types": "3.
|
|
24
|
-
"@docusaurus/utils": "3.
|
|
25
|
-
"@docusaurus/utils-validation": "3.
|
|
21
|
+
"@docusaurus/core": "3.4.0",
|
|
22
|
+
"@docusaurus/mdx-loader": "3.4.0",
|
|
23
|
+
"@docusaurus/types": "3.4.0",
|
|
24
|
+
"@docusaurus/utils": "3.4.0",
|
|
25
|
+
"@docusaurus/utils-validation": "3.4.0",
|
|
26
26
|
"fs-extra": "^11.1.1",
|
|
27
27
|
"tslib": "^2.6.0",
|
|
28
28
|
"webpack": "^5.88.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "49e9a2143274a8dd795659b417b470bc42abbd6e"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,8 @@ import type {
|
|
|
26
26
|
LoadedContent,
|
|
27
27
|
PageFrontMatter,
|
|
28
28
|
} from '@docusaurus/plugin-content-pages';
|
|
29
|
+
import type {RuleSetUseItem} from 'webpack';
|
|
30
|
+
import type {Options as MDXLoaderOptions} from '@docusaurus/mdx-loader/lib/loader';
|
|
29
31
|
|
|
30
32
|
export default function pluginContentPages(
|
|
31
33
|
context: LoadContext,
|
|
@@ -74,6 +76,42 @@ export default function pluginContentPages(
|
|
|
74
76
|
beforeDefaultRemarkPlugins,
|
|
75
77
|
} = options;
|
|
76
78
|
const contentDirs = getContentPathList(contentPaths);
|
|
79
|
+
|
|
80
|
+
function createMDXLoader(): RuleSetUseItem {
|
|
81
|
+
const loaderOptions: MDXLoaderOptions = {
|
|
82
|
+
admonitions,
|
|
83
|
+
remarkPlugins,
|
|
84
|
+
rehypePlugins,
|
|
85
|
+
beforeDefaultRehypePlugins,
|
|
86
|
+
beforeDefaultRemarkPlugins,
|
|
87
|
+
staticDirs: siteConfig.staticDirectories.map((dir) =>
|
|
88
|
+
path.resolve(siteDir, dir),
|
|
89
|
+
),
|
|
90
|
+
siteDir,
|
|
91
|
+
isMDXPartial: createAbsoluteFilePathMatcher(
|
|
92
|
+
options.exclude,
|
|
93
|
+
contentDirs,
|
|
94
|
+
),
|
|
95
|
+
metadataPath: (mdxPath: string) => {
|
|
96
|
+
// Note that metadataPath must be the same/in-sync as
|
|
97
|
+
// the path from createData for each MDX.
|
|
98
|
+
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
|
|
99
|
+
return path.join(dataDir, `${docuHash(aliasedSource)}.json`);
|
|
100
|
+
},
|
|
101
|
+
// Assets allow to convert some relative images paths to
|
|
102
|
+
// require(...) calls
|
|
103
|
+
createAssets: ({frontMatter}: {frontMatter: PageFrontMatter}) => ({
|
|
104
|
+
image: frontMatter.image,
|
|
105
|
+
}),
|
|
106
|
+
markdownConfig: siteConfig.markdown,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
111
|
+
options: loaderOptions,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
77
115
|
return {
|
|
78
116
|
module: {
|
|
79
117
|
rules: [
|
|
@@ -82,52 +120,7 @@ export default function pluginContentPages(
|
|
|
82
120
|
include: contentDirs
|
|
83
121
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
84
122
|
.map(addTrailingPathSeparator),
|
|
85
|
-
use: [
|
|
86
|
-
{
|
|
87
|
-
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
88
|
-
options: {
|
|
89
|
-
admonitions,
|
|
90
|
-
remarkPlugins,
|
|
91
|
-
rehypePlugins,
|
|
92
|
-
beforeDefaultRehypePlugins,
|
|
93
|
-
beforeDefaultRemarkPlugins,
|
|
94
|
-
staticDirs: siteConfig.staticDirectories.map((dir) =>
|
|
95
|
-
path.resolve(siteDir, dir),
|
|
96
|
-
),
|
|
97
|
-
siteDir,
|
|
98
|
-
isMDXPartial: createAbsoluteFilePathMatcher(
|
|
99
|
-
options.exclude,
|
|
100
|
-
contentDirs,
|
|
101
|
-
),
|
|
102
|
-
metadataPath: (mdxPath: string) => {
|
|
103
|
-
// Note that metadataPath must be the same/in-sync as
|
|
104
|
-
// the path from createData for each MDX.
|
|
105
|
-
const aliasedSource = aliasedSitePath(mdxPath, siteDir);
|
|
106
|
-
return path.join(
|
|
107
|
-
dataDir,
|
|
108
|
-
`${docuHash(aliasedSource)}.json`,
|
|
109
|
-
);
|
|
110
|
-
},
|
|
111
|
-
// Assets allow to convert some relative images paths to
|
|
112
|
-
// require(...) calls
|
|
113
|
-
createAssets: ({
|
|
114
|
-
frontMatter,
|
|
115
|
-
}: {
|
|
116
|
-
frontMatter: PageFrontMatter;
|
|
117
|
-
}) => ({
|
|
118
|
-
image: frontMatter.image,
|
|
119
|
-
}),
|
|
120
|
-
markdownConfig: siteConfig.markdown,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
loader: path.resolve(__dirname, './markdownLoader.js'),
|
|
125
|
-
options: {
|
|
126
|
-
// siteDir,
|
|
127
|
-
// contentPath,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
].filter(Boolean),
|
|
123
|
+
use: [createMDXLoader()],
|
|
131
124
|
},
|
|
132
125
|
],
|
|
133
126
|
},
|
package/lib/markdownLoader.d.ts
DELETED
|
@@ -1,8 +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
|
-
import type { LoaderContext } from 'webpack';
|
|
8
|
-
export default function markdownLoader(this: LoaderContext<undefined>, fileString: string): void;
|
package/lib/markdownLoader.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
function markdownLoader(fileString) {
|
|
10
|
-
const callback = this.async();
|
|
11
|
-
// const options = this.getOptions();
|
|
12
|
-
// TODO provide additional md processing here? like interlinking pages?
|
|
13
|
-
// fileString = linkify(fileString)
|
|
14
|
-
return callback(null, fileString);
|
|
15
|
-
}
|
|
16
|
-
exports.default = markdownLoader;
|
package/src/markdownLoader.ts
DELETED
|
@@ -1,22 +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 type {LoaderContext} from 'webpack';
|
|
9
|
-
|
|
10
|
-
export default function markdownLoader(
|
|
11
|
-
this: LoaderContext<undefined>,
|
|
12
|
-
fileString: string,
|
|
13
|
-
): void {
|
|
14
|
-
const callback = this.async();
|
|
15
|
-
|
|
16
|
-
// const options = this.getOptions();
|
|
17
|
-
|
|
18
|
-
// TODO provide additional md processing here? like interlinking pages?
|
|
19
|
-
// fileString = linkify(fileString)
|
|
20
|
-
|
|
21
|
-
return callback(null, fileString);
|
|
22
|
-
}
|