@docusaurus/plugin-content-pages 2.0.0-beta.15 → 2.0.0-beta.16
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 +13 -15
- package/package.json +9 -10
- package/src/index.ts +18 -25
- package/src/plugin-content-pages.d.ts +1 -2
package/lib/index.js
CHANGED
|
@@ -65,26 +65,24 @@ async function pluginContentPages(context, options) {
|
|
|
65
65
|
options.routeBasePath,
|
|
66
66
|
(0, utils_1.encodePath)((0, utils_1.fileToPath)(relativeSource)),
|
|
67
67
|
]);
|
|
68
|
-
if (isMarkdownSource(relativeSource)) {
|
|
69
|
-
const content = await fs_extra_1.default.readFile(source, 'utf-8');
|
|
70
|
-
const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
|
|
71
|
-
const frontMatter = (0, pageFrontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
|
|
72
|
-
return {
|
|
73
|
-
type: 'mdx',
|
|
74
|
-
permalink,
|
|
75
|
-
source: aliasedSourcePath,
|
|
76
|
-
title: (_a = frontMatter.title) !== null && _a !== void 0 ? _a : contentTitle,
|
|
77
|
-
description: (_b = frontMatter.description) !== null && _b !== void 0 ? _b : excerpt,
|
|
78
|
-
frontMatter,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
68
|
+
if (!isMarkdownSource(relativeSource)) {
|
|
82
69
|
return {
|
|
83
70
|
type: 'jsx',
|
|
84
71
|
permalink,
|
|
85
72
|
source: aliasedSourcePath,
|
|
86
73
|
};
|
|
87
74
|
}
|
|
75
|
+
const content = await fs_extra_1.default.readFile(source, 'utf-8');
|
|
76
|
+
const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
|
|
77
|
+
const frontMatter = (0, pageFrontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
|
|
78
|
+
return {
|
|
79
|
+
type: 'mdx',
|
|
80
|
+
permalink,
|
|
81
|
+
source: aliasedSourcePath,
|
|
82
|
+
title: (_a = frontMatter.title) !== null && _a !== void 0 ? _a : contentTitle,
|
|
83
|
+
description: (_b = frontMatter.description) !== null && _b !== void 0 ? _b : excerpt,
|
|
84
|
+
frontMatter,
|
|
85
|
+
};
|
|
88
86
|
}
|
|
89
87
|
return Promise.all(pagesFiles.map(toMetadata));
|
|
90
88
|
},
|
|
@@ -133,7 +131,7 @@ async function pluginContentPages(context, options) {
|
|
|
133
131
|
module: {
|
|
134
132
|
rules: [
|
|
135
133
|
{
|
|
136
|
-
test:
|
|
134
|
+
test: /\.mdx?$/i,
|
|
137
135
|
include: contentDirs
|
|
138
136
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
139
137
|
.map(utils_1.addTrailingPathSeparator),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.16",
|
|
4
4
|
"description": "Pages plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-pages.d.ts",
|
|
@@ -18,18 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
22
|
-
"@docusaurus/mdx-loader": "2.0.0-beta.
|
|
23
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
24
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
25
|
-
"fs-extra": "^10.0.
|
|
26
|
-
"globby": "^11.0.2",
|
|
21
|
+
"@docusaurus/core": "2.0.0-beta.16",
|
|
22
|
+
"@docusaurus/mdx-loader": "2.0.0-beta.16",
|
|
23
|
+
"@docusaurus/utils": "2.0.0-beta.16",
|
|
24
|
+
"@docusaurus/utils-validation": "2.0.0-beta.16",
|
|
25
|
+
"fs-extra": "^10.0.1",
|
|
27
26
|
"remark-admonitions": "^1.2.1",
|
|
28
27
|
"tslib": "^2.3.1",
|
|
29
|
-
"webpack": "^5.
|
|
28
|
+
"webpack": "^5.69.1"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.16"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -38,5 +37,5 @@
|
|
|
38
37
|
"engines": {
|
|
39
38
|
"node": ">=14"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
|
|
42
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -26,9 +26,7 @@ import type {
|
|
|
26
26
|
Plugin,
|
|
27
27
|
OptionValidationContext,
|
|
28
28
|
ValidationResult,
|
|
29
|
-
ConfigureWebpackUtils,
|
|
30
29
|
} from '@docusaurus/types';
|
|
31
|
-
import type {Configuration} from 'webpack';
|
|
32
30
|
import admonitions from 'remark-admonitions';
|
|
33
31
|
import {PluginOptionSchema} from './pluginOptionSchema';
|
|
34
32
|
import {validatePageFrontMatter} from './pageFrontMatter';
|
|
@@ -112,29 +110,28 @@ export default async function pluginContentPages(
|
|
|
112
110
|
options.routeBasePath,
|
|
113
111
|
encodePath(fileToPath(relativeSource)),
|
|
114
112
|
]);
|
|
115
|
-
if (isMarkdownSource(relativeSource)) {
|
|
116
|
-
const content = await fs.readFile(source, 'utf-8');
|
|
117
|
-
const {
|
|
118
|
-
frontMatter: unsafeFrontMatter,
|
|
119
|
-
contentTitle,
|
|
120
|
-
excerpt,
|
|
121
|
-
} = parseMarkdownString(content);
|
|
122
|
-
const frontMatter = validatePageFrontMatter(unsafeFrontMatter);
|
|
123
|
-
return {
|
|
124
|
-
type: 'mdx',
|
|
125
|
-
permalink,
|
|
126
|
-
source: aliasedSourcePath,
|
|
127
|
-
title: frontMatter.title ?? contentTitle,
|
|
128
|
-
description: frontMatter.description ?? excerpt,
|
|
129
|
-
frontMatter,
|
|
130
|
-
};
|
|
131
|
-
} else {
|
|
113
|
+
if (!isMarkdownSource(relativeSource)) {
|
|
132
114
|
return {
|
|
133
115
|
type: 'jsx',
|
|
134
116
|
permalink,
|
|
135
117
|
source: aliasedSourcePath,
|
|
136
118
|
};
|
|
137
119
|
}
|
|
120
|
+
const content = await fs.readFile(source, 'utf-8');
|
|
121
|
+
const {
|
|
122
|
+
frontMatter: unsafeFrontMatter,
|
|
123
|
+
contentTitle,
|
|
124
|
+
excerpt,
|
|
125
|
+
} = parseMarkdownString(content);
|
|
126
|
+
const frontMatter = validatePageFrontMatter(unsafeFrontMatter);
|
|
127
|
+
return {
|
|
128
|
+
type: 'mdx',
|
|
129
|
+
permalink,
|
|
130
|
+
source: aliasedSourcePath,
|
|
131
|
+
title: frontMatter.title ?? contentTitle,
|
|
132
|
+
description: frontMatter.description ?? excerpt,
|
|
133
|
+
frontMatter,
|
|
134
|
+
};
|
|
138
135
|
}
|
|
139
136
|
|
|
140
137
|
return Promise.all(pagesFiles.map(toMetadata));
|
|
@@ -179,11 +176,7 @@ export default async function pluginContentPages(
|
|
|
179
176
|
);
|
|
180
177
|
},
|
|
181
178
|
|
|
182
|
-
configureWebpack(
|
|
183
|
-
_config: Configuration,
|
|
184
|
-
isServer: boolean,
|
|
185
|
-
{getJSLoader}: ConfigureWebpackUtils,
|
|
186
|
-
) {
|
|
179
|
+
configureWebpack(_config, isServer, {getJSLoader}) {
|
|
187
180
|
const {
|
|
188
181
|
rehypePlugins,
|
|
189
182
|
remarkPlugins,
|
|
@@ -200,7 +193,7 @@ export default async function pluginContentPages(
|
|
|
200
193
|
module: {
|
|
201
194
|
rules: [
|
|
202
195
|
{
|
|
203
|
-
test:
|
|
196
|
+
test: /\.mdx?$/i,
|
|
204
197
|
include: contentDirs
|
|
205
198
|
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
|
|
206
199
|
.map(addTrailingPathSeparator),
|