@docusaurus/plugin-content-pages 0.0.0-5362 → 0.0.0-5363
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/frontMatter.js +1 -1
- package/lib/index.js +15 -2
- package/package.json +7 -7
- package/src/frontMatter.ts +2 -1
- package/src/index.ts +26 -2
- package/src/plugin-content-pages.d.ts +3 -0
package/lib/frontMatter.js
CHANGED
|
@@ -14,7 +14,7 @@ const PageFrontMatterSchema = utils_validation_1.Joi.object({
|
|
|
14
14
|
wrapperClassName: utils_validation_1.Joi.string(),
|
|
15
15
|
hide_table_of_contents: utils_validation_1.Joi.boolean(),
|
|
16
16
|
...utils_validation_1.FrontMatterTOCHeadingLevels,
|
|
17
|
-
});
|
|
17
|
+
}).concat(utils_validation_1.ContentVisibilitySchema);
|
|
18
18
|
function validatePageFrontMatter(frontMatter) {
|
|
19
19
|
return (0, utils_validation_1.validateFrontMatter)(frontMatter, PageFrontMatterSchema);
|
|
20
20
|
}
|
package/lib/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function pluginContentPages(context, options) {
|
|
|
45
45
|
cwd: contentPaths.contentPath,
|
|
46
46
|
ignore: options.exclude,
|
|
47
47
|
});
|
|
48
|
-
async function
|
|
48
|
+
async function processPageSourceFile(relativeSource) {
|
|
49
49
|
// Lookup in localized folder in priority
|
|
50
50
|
const contentPath = await (0, utils_1.getFolderContainingFile)(getContentPathList(contentPaths), relativeSource);
|
|
51
51
|
const source = path_1.default.join(contentPath, relativeSource);
|
|
@@ -65,6 +65,10 @@ function pluginContentPages(context, options) {
|
|
|
65
65
|
const content = await fs_extra_1.default.readFile(source, 'utf-8');
|
|
66
66
|
const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
|
|
67
67
|
const frontMatter = (0, frontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
|
|
68
|
+
if ((0, utils_1.isDraft)({ frontMatter })) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const unlisted = (0, utils_1.isUnlisted)({ frontMatter });
|
|
68
72
|
return {
|
|
69
73
|
type: 'mdx',
|
|
70
74
|
permalink,
|
|
@@ -72,9 +76,18 @@ function pluginContentPages(context, options) {
|
|
|
72
76
|
title: frontMatter.title ?? contentTitle,
|
|
73
77
|
description: frontMatter.description ?? excerpt,
|
|
74
78
|
frontMatter,
|
|
79
|
+
unlisted,
|
|
75
80
|
};
|
|
76
81
|
}
|
|
77
|
-
|
|
82
|
+
async function doProcessPageSourceFile(relativeSource) {
|
|
83
|
+
try {
|
|
84
|
+
return await processPageSourceFile(relativeSource);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
throw new Error(`Processing of page source file path=${relativeSource} failed.`, { cause: err });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return (await Promise.all(pagesFiles.map(doProcessPageSourceFile))).filter(Boolean);
|
|
78
91
|
},
|
|
79
92
|
async contentLoaded({ content, actions }) {
|
|
80
93
|
if (!content) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-pages",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5363",
|
|
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": "0.0.0-
|
|
22
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
23
|
-
"@docusaurus/types": "0.0.0-
|
|
24
|
-
"@docusaurus/utils": "0.0.0-
|
|
25
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-5363",
|
|
22
|
+
"@docusaurus/mdx-loader": "0.0.0-5363",
|
|
23
|
+
"@docusaurus/types": "0.0.0-5363",
|
|
24
|
+
"@docusaurus/utils": "0.0.0-5363",
|
|
25
|
+
"@docusaurus/utils-validation": "0.0.0-5363",
|
|
26
26
|
"fs-extra": "^10.1.0",
|
|
27
27
|
"tslib": "^2.4.0",
|
|
28
28
|
"webpack": "^5.74.0"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=16.14"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "dbe94ffd19b3e3eb1dcb64e85b61350045faa250"
|
|
38
38
|
}
|
package/src/frontMatter.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Joi,
|
|
10
10
|
validateFrontMatter,
|
|
11
11
|
FrontMatterTOCHeadingLevels,
|
|
12
|
+
ContentVisibilitySchema,
|
|
12
13
|
} from '@docusaurus/utils-validation';
|
|
13
14
|
import type {FrontMatter} from '@docusaurus/plugin-content-pages';
|
|
14
15
|
|
|
@@ -18,7 +19,7 @@ const PageFrontMatterSchema = Joi.object<FrontMatter>({
|
|
|
18
19
|
wrapperClassName: Joi.string(),
|
|
19
20
|
hide_table_of_contents: Joi.boolean(),
|
|
20
21
|
...FrontMatterTOCHeadingLevels,
|
|
21
|
-
});
|
|
22
|
+
}).concat(ContentVisibilitySchema);
|
|
22
23
|
|
|
23
24
|
export function validatePageFrontMatter(frontMatter: {
|
|
24
25
|
[key: string]: unknown;
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
normalizeUrl,
|
|
21
21
|
DEFAULT_PLUGIN_ID,
|
|
22
22
|
parseMarkdownString,
|
|
23
|
+
isUnlisted,
|
|
24
|
+
isDraft,
|
|
23
25
|
} from '@docusaurus/utils';
|
|
24
26
|
import {validatePageFrontMatter} from './frontMatter';
|
|
25
27
|
|
|
@@ -82,7 +84,9 @@ export default function pluginContentPages(
|
|
|
82
84
|
ignore: options.exclude,
|
|
83
85
|
});
|
|
84
86
|
|
|
85
|
-
async function
|
|
87
|
+
async function processPageSourceFile(
|
|
88
|
+
relativeSource: string,
|
|
89
|
+
): Promise<Metadata | undefined> {
|
|
86
90
|
// Lookup in localized folder in priority
|
|
87
91
|
const contentPath = await getFolderContainingFile(
|
|
88
92
|
getContentPathList(contentPaths),
|
|
@@ -110,6 +114,12 @@ export default function pluginContentPages(
|
|
|
110
114
|
excerpt,
|
|
111
115
|
} = parseMarkdownString(content);
|
|
112
116
|
const frontMatter = validatePageFrontMatter(unsafeFrontMatter);
|
|
117
|
+
|
|
118
|
+
if (isDraft({frontMatter})) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const unlisted = isUnlisted({frontMatter});
|
|
122
|
+
|
|
113
123
|
return {
|
|
114
124
|
type: 'mdx',
|
|
115
125
|
permalink,
|
|
@@ -117,10 +127,24 @@ export default function pluginContentPages(
|
|
|
117
127
|
title: frontMatter.title ?? contentTitle,
|
|
118
128
|
description: frontMatter.description ?? excerpt,
|
|
119
129
|
frontMatter,
|
|
130
|
+
unlisted,
|
|
120
131
|
};
|
|
121
132
|
}
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
async function doProcessPageSourceFile(relativeSource: string) {
|
|
135
|
+
try {
|
|
136
|
+
return await processPageSourceFile(relativeSource);
|
|
137
|
+
} catch (err) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`Processing of page source file path=${relativeSource} failed.`,
|
|
140
|
+
{cause: err as Error},
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
await Promise.all(pagesFiles.map(doProcessPageSourceFile))
|
|
147
|
+
).filter(Boolean) as Metadata[];
|
|
124
148
|
},
|
|
125
149
|
|
|
126
150
|
async contentLoaded({content, actions}) {
|
|
@@ -27,6 +27,8 @@ declare module '@docusaurus/plugin-content-pages' {
|
|
|
27
27
|
readonly hide_table_of_contents?: string;
|
|
28
28
|
readonly toc_min_heading_level?: number;
|
|
29
29
|
readonly toc_max_heading_level?: number;
|
|
30
|
+
readonly draft?: boolean;
|
|
31
|
+
readonly unlisted?: boolean;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type JSXPageMetadata = {
|
|
@@ -42,6 +44,7 @@ declare module '@docusaurus/plugin-content-pages' {
|
|
|
42
44
|
frontMatter: FrontMatter & {[key: string]: unknown};
|
|
43
45
|
title?: string;
|
|
44
46
|
description?: string;
|
|
47
|
+
unlisted: boolean;
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
export type Metadata = JSXPageMetadata | MDXPageMetadata;
|