@docusaurus/plugin-sitemap 2.0.0-beta.20 → 2.0.0-beta.21
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 +4 -2
- package/lib/options.d.ts +5 -0
- package/lib/options.js +3 -0
- package/package.json +9 -8
- package/src/createSitemap.ts +2 -2
- package/src/index.ts +4 -2
- package/src/options.ts +9 -1
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.validateOptions = void 0;
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
14
|
const createSitemap_1 = tslib_1.__importDefault(require("./createSitemap"));
|
|
14
15
|
function pluginSitemap(context, options) {
|
|
15
16
|
return {
|
|
@@ -21,12 +22,13 @@ function pluginSitemap(context, options) {
|
|
|
21
22
|
// Generate sitemap.
|
|
22
23
|
const generatedSitemap = await (0, createSitemap_1.default)(siteConfig, routesPaths, head, options);
|
|
23
24
|
// Write sitemap file.
|
|
24
|
-
const sitemapPath = path_1.default.join(outDir,
|
|
25
|
+
const sitemapPath = path_1.default.join(outDir, options.filename);
|
|
25
26
|
try {
|
|
26
27
|
await fs_extra_1.default.outputFile(sitemapPath, generatedSitemap);
|
|
27
28
|
}
|
|
28
29
|
catch (err) {
|
|
29
|
-
|
|
30
|
+
logger_1.default.error('Writing sitemap failed.');
|
|
31
|
+
throw err;
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
};
|
package/lib/options.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export declare type PluginOptions = {
|
|
|
16
16
|
* sitemap. Note that you may need to include the base URL in here.
|
|
17
17
|
*/
|
|
18
18
|
ignorePatterns: string[];
|
|
19
|
+
/**
|
|
20
|
+
* The path to the created sitemap file, relative to the output directory.
|
|
21
|
+
* Useful if you have two plugin instances outputting two files.
|
|
22
|
+
*/
|
|
23
|
+
filename: string;
|
|
19
24
|
};
|
|
20
25
|
export declare type Options = Partial<PluginOptions>;
|
|
21
26
|
export declare const DEFAULT_OPTIONS: PluginOptions;
|
package/lib/options.js
CHANGED
|
@@ -13,8 +13,10 @@ exports.DEFAULT_OPTIONS = {
|
|
|
13
13
|
changefreq: sitemap_1.EnumChangefreq.WEEKLY,
|
|
14
14
|
priority: 0.5,
|
|
15
15
|
ignorePatterns: [],
|
|
16
|
+
filename: 'sitemap.xml',
|
|
16
17
|
};
|
|
17
18
|
const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
19
|
+
// @ts-expect-error: forbidden
|
|
18
20
|
cacheTime: utils_validation_1.Joi.forbidden().messages({
|
|
19
21
|
'any.unknown': 'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
|
|
20
22
|
}),
|
|
@@ -28,6 +30,7 @@ const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
|
28
30
|
trailingSlash: utils_validation_1.Joi.forbidden().messages({
|
|
29
31
|
'any.unknown': 'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
|
|
30
32
|
}),
|
|
33
|
+
filename: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.filename),
|
|
31
34
|
});
|
|
32
35
|
function validateOptions({ validate, options, }) {
|
|
33
36
|
const validatedOptions = validate(PluginOptionSchema, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-sitemap",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
4
|
"description": "Simple sitemap generation plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,23 +18,24 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
22
|
-
"@docusaurus/
|
|
23
|
-
"@docusaurus/utils
|
|
24
|
-
"@docusaurus/utils-
|
|
21
|
+
"@docusaurus/core": "2.0.0-beta.21",
|
|
22
|
+
"@docusaurus/logger": "2.0.0-beta.21",
|
|
23
|
+
"@docusaurus/utils": "2.0.0-beta.21",
|
|
24
|
+
"@docusaurus/utils-common": "2.0.0-beta.21",
|
|
25
|
+
"@docusaurus/utils-validation": "2.0.0-beta.21",
|
|
25
26
|
"fs-extra": "^10.1.0",
|
|
26
27
|
"sitemap": "^7.1.1",
|
|
27
28
|
"tslib": "^2.4.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.21"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"react": "^16.8.4 || ^17.0.0",
|
|
34
35
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
|
-
"node": ">=14"
|
|
38
|
+
"node": ">=16.14"
|
|
38
39
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "69ac49fc6909517f13615ee40290c4bd00c39df4"
|
|
40
41
|
}
|
package/src/createSitemap.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type {ReactElement} from 'react';
|
|
8
9
|
import {SitemapStream, streamToPromise} from 'sitemap';
|
|
9
10
|
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
|
10
11
|
import {createMatcher} from '@docusaurus/utils';
|
|
11
12
|
import type {DocusaurusConfig} from '@docusaurus/types';
|
|
12
13
|
import type {HelmetServerState} from 'react-helmet-async';
|
|
13
14
|
import type {PluginOptions} from './options';
|
|
14
|
-
import type {ReactElement} from 'react';
|
|
15
15
|
|
|
16
16
|
export default async function createSitemap(
|
|
17
17
|
siteConfig: DocusaurusConfig,
|
|
@@ -35,7 +35,7 @@ export default async function createSitemap(
|
|
|
35
35
|
}
|
|
36
36
|
// https://github.com/staylor/react-helmet-async/pull/167
|
|
37
37
|
const meta = head[route]?.meta.toComponent() as unknown as
|
|
38
|
-
| ReactElement[]
|
|
38
|
+
| ReactElement<{name?: string; content?: string}>[]
|
|
39
39
|
| undefined;
|
|
40
40
|
return !meta?.some(
|
|
41
41
|
(tag) => tag.props.name === 'robots' && tag.props.content === 'noindex',
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
|
+
import logger from '@docusaurus/logger';
|
|
10
11
|
import createSitemap from './createSitemap';
|
|
11
12
|
import type {PluginOptions, Options} from './options';
|
|
12
13
|
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
@@ -31,11 +32,12 @@ export default function pluginSitemap(
|
|
|
31
32
|
);
|
|
32
33
|
|
|
33
34
|
// Write sitemap file.
|
|
34
|
-
const sitemapPath = path.join(outDir,
|
|
35
|
+
const sitemapPath = path.join(outDir, options.filename);
|
|
35
36
|
try {
|
|
36
37
|
await fs.outputFile(sitemapPath, generatedSitemap);
|
|
37
38
|
} catch (err) {
|
|
38
|
-
|
|
39
|
+
logger.error('Writing sitemap failed.');
|
|
40
|
+
throw err;
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
};
|
package/src/options.ts
CHANGED
|
@@ -19,6 +19,11 @@ export type PluginOptions = {
|
|
|
19
19
|
* sitemap. Note that you may need to include the base URL in here.
|
|
20
20
|
*/
|
|
21
21
|
ignorePatterns: string[];
|
|
22
|
+
/**
|
|
23
|
+
* The path to the created sitemap file, relative to the output directory.
|
|
24
|
+
* Useful if you have two plugin instances outputting two files.
|
|
25
|
+
*/
|
|
26
|
+
filename: string;
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
export type Options = Partial<PluginOptions>;
|
|
@@ -27,9 +32,11 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|
|
27
32
|
changefreq: EnumChangefreq.WEEKLY,
|
|
28
33
|
priority: 0.5,
|
|
29
34
|
ignorePatterns: [],
|
|
35
|
+
filename: 'sitemap.xml',
|
|
30
36
|
};
|
|
31
37
|
|
|
32
|
-
const PluginOptionSchema = Joi.object({
|
|
38
|
+
const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
39
|
+
// @ts-expect-error: forbidden
|
|
33
40
|
cacheTime: Joi.forbidden().messages({
|
|
34
41
|
'any.unknown':
|
|
35
42
|
'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
|
|
@@ -45,6 +52,7 @@ const PluginOptionSchema = Joi.object({
|
|
|
45
52
|
'any.unknown':
|
|
46
53
|
'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
|
|
47
54
|
}),
|
|
55
|
+
filename: Joi.string().default(DEFAULT_OPTIONS.filename),
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
export function validateOptions({
|