@docusaurus/plugin-content-pages 3.1.1 → 3.2.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 +12 -0
- package/package.json +7 -7
- package/src/index.ts +15 -2
package/lib/index.js
CHANGED
|
@@ -98,8 +98,18 @@ function pluginContentPages(context, options) {
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
const { addRoute, createData } = actions;
|
|
101
|
+
function createPageRouteMetadata(metadata) {
|
|
102
|
+
return {
|
|
103
|
+
sourceFilePath: (0, utils_1.aliasedSitePathToRelativePath)(metadata.source),
|
|
104
|
+
// TODO add support for last updated date in the page plugin
|
|
105
|
+
// at least for Markdown files
|
|
106
|
+
// lastUpdatedAt: metadata.lastUpdatedAt,
|
|
107
|
+
lastUpdatedAt: undefined,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
101
110
|
await Promise.all(content.map(async (metadata) => {
|
|
102
111
|
const { permalink, source } = metadata;
|
|
112
|
+
const routeMetadata = createPageRouteMetadata(metadata);
|
|
103
113
|
if (metadata.type === 'mdx') {
|
|
104
114
|
await createData(
|
|
105
115
|
// Note that this created data path must be in sync with
|
|
@@ -109,6 +119,7 @@ function pluginContentPages(context, options) {
|
|
|
109
119
|
path: permalink,
|
|
110
120
|
component: options.mdxPageComponent,
|
|
111
121
|
exact: true,
|
|
122
|
+
metadata: routeMetadata,
|
|
112
123
|
modules: {
|
|
113
124
|
content: source,
|
|
114
125
|
},
|
|
@@ -119,6 +130,7 @@ function pluginContentPages(context, options) {
|
|
|
119
130
|
path: permalink,
|
|
120
131
|
component: source,
|
|
121
132
|
exact: true,
|
|
133
|
+
metadata: routeMetadata,
|
|
122
134
|
modules: {
|
|
123
135
|
config: `@generated/docusaurus.config`,
|
|
124
136
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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.2.0",
|
|
22
|
+
"@docusaurus/mdx-loader": "3.2.0",
|
|
23
|
+
"@docusaurus/types": "3.2.0",
|
|
24
|
+
"@docusaurus/utils": "3.2.0",
|
|
25
|
+
"@docusaurus/utils-validation": "3.2.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": "5af143651b26b39761361acd96e9c5be7ba0cb25"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
encodePath,
|
|
12
12
|
fileToPath,
|
|
13
13
|
aliasedSitePath,
|
|
14
|
+
aliasedSitePathToRelativePath,
|
|
14
15
|
docuHash,
|
|
15
16
|
getPluginI18nPath,
|
|
16
17
|
getFolderContainingFile,
|
|
@@ -24,8 +25,7 @@ import {
|
|
|
24
25
|
isDraft,
|
|
25
26
|
} from '@docusaurus/utils';
|
|
26
27
|
import {validatePageFrontMatter} from './frontMatter';
|
|
27
|
-
|
|
28
|
-
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
28
|
+
import type {LoadContext, Plugin, RouteMetadata} from '@docusaurus/types';
|
|
29
29
|
import type {PagesContentPaths} from './types';
|
|
30
30
|
import type {
|
|
31
31
|
PluginOptions,
|
|
@@ -159,9 +159,20 @@ export default function pluginContentPages(
|
|
|
159
159
|
|
|
160
160
|
const {addRoute, createData} = actions;
|
|
161
161
|
|
|
162
|
+
function createPageRouteMetadata(metadata: Metadata): RouteMetadata {
|
|
163
|
+
return {
|
|
164
|
+
sourceFilePath: aliasedSitePathToRelativePath(metadata.source),
|
|
165
|
+
// TODO add support for last updated date in the page plugin
|
|
166
|
+
// at least for Markdown files
|
|
167
|
+
// lastUpdatedAt: metadata.lastUpdatedAt,
|
|
168
|
+
lastUpdatedAt: undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
162
172
|
await Promise.all(
|
|
163
173
|
content.map(async (metadata) => {
|
|
164
174
|
const {permalink, source} = metadata;
|
|
175
|
+
const routeMetadata = createPageRouteMetadata(metadata);
|
|
165
176
|
if (metadata.type === 'mdx') {
|
|
166
177
|
await createData(
|
|
167
178
|
// Note that this created data path must be in sync with
|
|
@@ -173,6 +184,7 @@ export default function pluginContentPages(
|
|
|
173
184
|
path: permalink,
|
|
174
185
|
component: options.mdxPageComponent,
|
|
175
186
|
exact: true,
|
|
187
|
+
metadata: routeMetadata,
|
|
176
188
|
modules: {
|
|
177
189
|
content: source,
|
|
178
190
|
},
|
|
@@ -182,6 +194,7 @@ export default function pluginContentPages(
|
|
|
182
194
|
path: permalink,
|
|
183
195
|
component: source,
|
|
184
196
|
exact: true,
|
|
197
|
+
metadata: routeMetadata,
|
|
185
198
|
modules: {
|
|
186
199
|
config: `@generated/docusaurus.config`,
|
|
187
200
|
},
|