@docusaurus/plugin-sitemap 4.0.0-canary-6936 → 4.0.0-canary-6937
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/createSitemapItem.js +1 -3
- package/lib/options.d.ts +1 -11
- package/lib/options.js +17 -19
- package/lib/types.d.ts +2 -1
- package/package.json +9 -9
- package/src/createSitemapItem.ts +1 -3
- package/src/options.ts +24 -36
- package/src/types.ts +1 -1
package/lib/createSitemapItem.js
CHANGED
|
@@ -61,7 +61,7 @@ async function getRouteLastmod({ route, lastmod, vcs, }) {
|
|
|
61
61
|
return lastUpdatedAt != null ? formatLastmod(lastUpdatedAt, lastmod) : null;
|
|
62
62
|
}
|
|
63
63
|
async function createSitemapItem({ route, siteConfig, options, }) {
|
|
64
|
-
const {
|
|
64
|
+
const { lastmod } = options;
|
|
65
65
|
return {
|
|
66
66
|
url: (0, utils_1.normalizeUrl)([
|
|
67
67
|
siteConfig.url,
|
|
@@ -70,8 +70,6 @@ async function createSitemapItem({ route, siteConfig, options, }) {
|
|
|
70
70
|
baseUrl: siteConfig.baseUrl,
|
|
71
71
|
}),
|
|
72
72
|
]),
|
|
73
|
-
changefreq,
|
|
74
|
-
priority,
|
|
75
73
|
lastmod: await getRouteLastmod({
|
|
76
74
|
route,
|
|
77
75
|
lastmod,
|
package/lib/options.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { OptionValidationContext } from '@docusaurus/types';
|
|
8
|
-
import type {
|
|
8
|
+
import type { LastModOption, SitemapItem, CreateSitemapItemsFn, CreateSitemapItemsParams } from './types';
|
|
9
9
|
export type PluginOptions = {
|
|
10
10
|
/**
|
|
11
11
|
* The path to the created sitemap file, relative to the output directory.
|
|
@@ -26,16 +26,6 @@ export type PluginOptions = {
|
|
|
26
26
|
* @see https://www.w3.org/TR/NOTE-datetime
|
|
27
27
|
*/
|
|
28
28
|
lastmod: LastModOption | null;
|
|
29
|
-
/**
|
|
30
|
-
* TODO Docusaurus v4 breaking change: remove useless option
|
|
31
|
-
* @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions
|
|
32
|
-
*/
|
|
33
|
-
changefreq: ChangeFreq | null;
|
|
34
|
-
/**
|
|
35
|
-
* TODO Docusaurus v4 breaking change: remove useless option
|
|
36
|
-
* @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions
|
|
37
|
-
*/
|
|
38
|
-
priority: number | null;
|
|
39
29
|
/** Allow control over the construction of SitemapItems */
|
|
40
30
|
createSitemapItems?: CreateSitemapItemsOption;
|
|
41
31
|
};
|
package/lib/options.js
CHANGED
|
@@ -8,37 +8,35 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.DEFAULT_OPTIONS = void 0;
|
|
10
10
|
exports.validateOptions = validateOptions;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
11
13
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
12
14
|
const types_1 = require("./types");
|
|
13
15
|
exports.DEFAULT_OPTIONS = {
|
|
14
16
|
filename: 'sitemap.xml',
|
|
15
17
|
ignorePatterns: [],
|
|
16
18
|
lastmod: 'date',
|
|
17
|
-
// TODO Docusaurus v4 breaking change
|
|
18
|
-
// those options are useless and should be removed
|
|
19
|
-
changefreq: 'weekly',
|
|
20
|
-
priority: 0.5,
|
|
21
19
|
};
|
|
20
|
+
// TODO Docusaurus v5: remove these migration errors
|
|
21
|
+
// Removed in Docusaurus v4: Google ignores <changefreq> and <priority>,
|
|
22
|
+
// and the same value for all routes does not make sense anyway
|
|
23
|
+
// Users can still emit them per-route with createSitemapItems()
|
|
24
|
+
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
25
|
+
function removedOptionSchema(option) {
|
|
26
|
+
return utils_validation_1.Joi.any()
|
|
27
|
+
.forbidden()
|
|
28
|
+
.messages({
|
|
29
|
+
'any.unknown': `The sitemap plugin ${logger_1.default.code(option)} option has been removed in Docusaurus v4. Please remove it from your config.
|
|
30
|
+
If you still want to emit this sitemap tag, use the ${logger_1.default.code('createSitemapItems')} option instead: ${logger_1.default.url('https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-sitemap#changefreq-priority')}`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
22
33
|
const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
23
34
|
// @ts-expect-error: forbidden
|
|
24
35
|
cacheTime: utils_validation_1.Joi.forbidden().messages({
|
|
25
36
|
'any.unknown': 'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
|
|
26
37
|
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
30
|
-
changefreq: utils_validation_1.Joi.string()
|
|
31
|
-
.valid(null, ...types_1.ChangeFreqList)
|
|
32
|
-
.default(exports.DEFAULT_OPTIONS.changefreq),
|
|
33
|
-
// TODO remove for Docusaurus v4 breaking changes?
|
|
34
|
-
// This is not even used by Google crawlers
|
|
35
|
-
// The priority is "relative", and using the same priority for all routes
|
|
36
|
-
// does not make sense according to the spec
|
|
37
|
-
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
38
|
-
// See also https://www.sitemaps.org/protocol.html
|
|
39
|
-
priority: utils_validation_1.Joi.alternatives()
|
|
40
|
-
.try(utils_validation_1.Joi.valid(null), utils_validation_1.Joi.number().min(0).max(1))
|
|
41
|
-
.default(exports.DEFAULT_OPTIONS.priority),
|
|
38
|
+
changefreq: removedOptionSchema('changefreq'),
|
|
39
|
+
priority: removedOptionSchema('priority'),
|
|
42
40
|
lastmod: utils_validation_1.Joi.string()
|
|
43
41
|
.valid(null, ...types_1.LastModOptionList)
|
|
44
42
|
.default(exports.DEFAULT_OPTIONS.lastmod),
|
package/lib/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { DocusaurusConfig, RouteConfig } from '@docusaurus/types';
|
|
|
8
8
|
export declare const LastModOptionList: readonly ['date', 'datetime'];
|
|
9
9
|
export type LastModOption = (typeof LastModOptionList)[number];
|
|
10
10
|
export declare const ChangeFreqList: readonly ['hourly', 'daily', 'weekly', 'monthly', 'yearly', 'always', 'never'];
|
|
11
|
-
|
|
11
|
+
type ChangeFreq = (typeof ChangeFreqList)[number];
|
|
12
12
|
export type SitemapItem = {
|
|
13
13
|
/**
|
|
14
14
|
* URL of the page.
|
|
@@ -51,3 +51,4 @@ export type CreateSitemapItemsParams = {
|
|
|
51
51
|
routes: RouteConfig[];
|
|
52
52
|
};
|
|
53
53
|
export type CreateSitemapItemsFn = (params: CreateSitemapItemsParams) => Promise<SitemapItem[]>;
|
|
54
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-sitemap",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6937",
|
|
4
4
|
"description": "Simple sitemap generation plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@docusaurus/core": "4.0.0-canary-
|
|
18
|
-
"@docusaurus/fs": "4.0.0-canary-
|
|
19
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
20
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
21
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
22
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
23
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
17
|
+
"@docusaurus/core": "4.0.0-canary-6937",
|
|
18
|
+
"@docusaurus/fs": "4.0.0-canary-6937",
|
|
19
|
+
"@docusaurus/glob": "4.0.0-canary-6937",
|
|
20
|
+
"@docusaurus/logger": "4.0.0-canary-6937",
|
|
21
|
+
"@docusaurus/types": "4.0.0-canary-6937",
|
|
22
|
+
"@docusaurus/utils": "4.0.0-canary-6937",
|
|
23
|
+
"@docusaurus/utils-common": "4.0.0-canary-6937",
|
|
24
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6937",
|
|
25
25
|
"lodash": "^4.18.1",
|
|
26
26
|
"sitemap": "^9.0.1",
|
|
27
27
|
"tslib": "^2.8.1"
|
package/src/createSitemapItem.ts
CHANGED
|
@@ -94,7 +94,7 @@ export async function createSitemapItem({
|
|
|
94
94
|
siteConfig: DocusaurusConfig;
|
|
95
95
|
options: PluginOptions;
|
|
96
96
|
}): Promise<SitemapItem> {
|
|
97
|
-
const {
|
|
97
|
+
const {lastmod} = options;
|
|
98
98
|
return {
|
|
99
99
|
url: normalizeUrl([
|
|
100
100
|
siteConfig.url,
|
|
@@ -103,8 +103,6 @@ export async function createSitemapItem({
|
|
|
103
103
|
baseUrl: siteConfig.baseUrl,
|
|
104
104
|
}),
|
|
105
105
|
]),
|
|
106
|
-
changefreq,
|
|
107
|
-
priority,
|
|
108
106
|
lastmod: await getRouteLastmod({
|
|
109
107
|
route,
|
|
110
108
|
lastmod,
|
package/src/options.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import logger from '@docusaurus/logger';
|
|
8
9
|
import {Joi} from '@docusaurus/utils-validation';
|
|
9
|
-
import {
|
|
10
|
+
import {LastModOptionList} from './types';
|
|
10
11
|
import type {OptionValidationContext} from '@docusaurus/types';
|
|
11
12
|
import type {
|
|
12
|
-
ChangeFreq,
|
|
13
13
|
LastModOption,
|
|
14
14
|
SitemapItem,
|
|
15
15
|
CreateSitemapItemsFn,
|
|
@@ -39,18 +39,6 @@ export type PluginOptions = {
|
|
|
39
39
|
*/
|
|
40
40
|
lastmod: LastModOption | null;
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* TODO Docusaurus v4 breaking change: remove useless option
|
|
44
|
-
* @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions
|
|
45
|
-
*/
|
|
46
|
-
changefreq: ChangeFreq | null;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* TODO Docusaurus v4 breaking change: remove useless option
|
|
50
|
-
* @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions
|
|
51
|
-
*/
|
|
52
|
-
priority: number | null;
|
|
53
|
-
|
|
54
42
|
/** Allow control over the construction of SitemapItems */
|
|
55
43
|
createSitemapItems?: CreateSitemapItemsOption;
|
|
56
44
|
};
|
|
@@ -66,15 +54,29 @@ export type Options = Partial<PluginOptions>;
|
|
|
66
54
|
export const DEFAULT_OPTIONS: PluginOptions = {
|
|
67
55
|
filename: 'sitemap.xml',
|
|
68
56
|
ignorePatterns: [],
|
|
69
|
-
|
|
70
57
|
lastmod: 'date',
|
|
71
|
-
|
|
72
|
-
// TODO Docusaurus v4 breaking change
|
|
73
|
-
// those options are useless and should be removed
|
|
74
|
-
changefreq: 'weekly',
|
|
75
|
-
priority: 0.5,
|
|
76
58
|
};
|
|
77
59
|
|
|
60
|
+
// TODO Docusaurus v5: remove these migration errors
|
|
61
|
+
// Removed in Docusaurus v4: Google ignores <changefreq> and <priority>,
|
|
62
|
+
// and the same value for all routes does not make sense anyway
|
|
63
|
+
// Users can still emit them per-route with createSitemapItems()
|
|
64
|
+
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
65
|
+
function removedOptionSchema(option: 'changefreq' | 'priority') {
|
|
66
|
+
return Joi.any()
|
|
67
|
+
.forbidden()
|
|
68
|
+
.messages({
|
|
69
|
+
'any.unknown': `The sitemap plugin ${logger.code(
|
|
70
|
+
option,
|
|
71
|
+
)} option has been removed in Docusaurus v4. Please remove it from your config.
|
|
72
|
+
If you still want to emit this sitemap tag, use the ${logger.code(
|
|
73
|
+
'createSitemapItems',
|
|
74
|
+
)} option instead: ${logger.url(
|
|
75
|
+
'https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-sitemap#changefreq-priority',
|
|
76
|
+
)}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
78
80
|
const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
79
81
|
// @ts-expect-error: forbidden
|
|
80
82
|
cacheTime: Joi.forbidden().messages({
|
|
@@ -82,22 +84,8 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
|
82
84
|
'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
|
|
83
85
|
}),
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
88
|
-
changefreq: Joi.string()
|
|
89
|
-
.valid(null, ...ChangeFreqList)
|
|
90
|
-
.default(DEFAULT_OPTIONS.changefreq),
|
|
91
|
-
|
|
92
|
-
// TODO remove for Docusaurus v4 breaking changes?
|
|
93
|
-
// This is not even used by Google crawlers
|
|
94
|
-
// The priority is "relative", and using the same priority for all routes
|
|
95
|
-
// does not make sense according to the spec
|
|
96
|
-
// See also https://github.com/facebook/docusaurus/issues/2604
|
|
97
|
-
// See also https://www.sitemaps.org/protocol.html
|
|
98
|
-
priority: Joi.alternatives()
|
|
99
|
-
.try(Joi.valid(null), Joi.number().min(0).max(1))
|
|
100
|
-
.default(DEFAULT_OPTIONS.priority),
|
|
87
|
+
changefreq: removedOptionSchema('changefreq'),
|
|
88
|
+
priority: removedOptionSchema('priority'),
|
|
101
89
|
|
|
102
90
|
lastmod: Joi.string()
|
|
103
91
|
.valid(null, ...LastModOptionList)
|
package/src/types.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const ChangeFreqList = [
|
|
|
24
24
|
'never',
|
|
25
25
|
] as const;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
type ChangeFreq = (typeof ChangeFreqList)[number];
|
|
28
28
|
|
|
29
29
|
// We re-recreate our own type because the "sitemap" lib types are not good
|
|
30
30
|
export type SitemapItem = {
|