@docusaurus/plugin-sitemap 3.9.1-canary-6425 → 3.9.2-alpha.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/createSitemapItem.js +11 -7
- package/package.json +8 -8
- package/src/createSitemapItem.ts +16 -7
package/lib/createSitemapItem.js
CHANGED
|
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createSitemapItem = createSitemapItem;
|
|
10
10
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
|
-
async function getRouteLastUpdatedAt(route) {
|
|
12
|
+
async function getRouteLastUpdatedAt(route, vcs) {
|
|
13
13
|
// Important to bail-out early here
|
|
14
|
-
// This can lead to duplicated
|
|
14
|
+
// This can lead to duplicated VCS calls and performance problems
|
|
15
15
|
// See https://github.com/facebook/docusaurus/pull/11211
|
|
16
16
|
if (route.metadata?.lastUpdatedAt === null) {
|
|
17
17
|
return null;
|
|
@@ -20,8 +20,8 @@ async function getRouteLastUpdatedAt(route) {
|
|
|
20
20
|
return route.metadata?.lastUpdatedAt;
|
|
21
21
|
}
|
|
22
22
|
if (route.metadata?.sourceFilePath) {
|
|
23
|
-
const
|
|
24
|
-
return
|
|
23
|
+
const lastUpdateInfo = await vcs.getFileLastUpdateInfo(route.metadata?.sourceFilePath);
|
|
24
|
+
return lastUpdateInfo?.timestamp ?? null;
|
|
25
25
|
}
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
@@ -33,11 +33,11 @@ function formatLastmod(timestamp, lastmodOption) {
|
|
|
33
33
|
const format = LastmodFormatters[lastmodOption];
|
|
34
34
|
return format(timestamp);
|
|
35
35
|
}
|
|
36
|
-
async function getRouteLastmod({ route, lastmod, }) {
|
|
36
|
+
async function getRouteLastmod({ route, lastmod, vcs, }) {
|
|
37
37
|
if (lastmod === null) {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
const lastUpdatedAt = (await getRouteLastUpdatedAt(route)) ?? null;
|
|
40
|
+
const lastUpdatedAt = (await getRouteLastUpdatedAt(route, vcs)) ?? null;
|
|
41
41
|
return lastUpdatedAt ? formatLastmod(lastUpdatedAt, lastmod) : null;
|
|
42
42
|
}
|
|
43
43
|
async function createSitemapItem({ route, siteConfig, options, }) {
|
|
@@ -52,6 +52,10 @@ async function createSitemapItem({ route, siteConfig, options, }) {
|
|
|
52
52
|
]),
|
|
53
53
|
changefreq,
|
|
54
54
|
priority,
|
|
55
|
-
lastmod: await getRouteLastmod({
|
|
55
|
+
lastmod: await getRouteLastmod({
|
|
56
|
+
route,
|
|
57
|
+
lastmod,
|
|
58
|
+
vcs: siteConfig.future.experimental_vcs,
|
|
59
|
+
}),
|
|
56
60
|
};
|
|
57
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-sitemap",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2-alpha.0",
|
|
4
4
|
"description": "Simple sitemap generation plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "3.9.
|
|
22
|
-
"@docusaurus/logger": "3.9.
|
|
23
|
-
"@docusaurus/types": "3.9.
|
|
24
|
-
"@docusaurus/utils": "3.9.
|
|
25
|
-
"@docusaurus/utils-common": "3.9.
|
|
26
|
-
"@docusaurus/utils-validation": "3.9.
|
|
21
|
+
"@docusaurus/core": "3.9.2-alpha.0",
|
|
22
|
+
"@docusaurus/logger": "3.9.2-alpha.0",
|
|
23
|
+
"@docusaurus/types": "3.9.2-alpha.0",
|
|
24
|
+
"@docusaurus/utils": "3.9.2-alpha.0",
|
|
25
|
+
"@docusaurus/utils-common": "3.9.2-alpha.0",
|
|
26
|
+
"@docusaurus/utils-validation": "3.9.2-alpha.0",
|
|
27
27
|
"fs-extra": "^11.1.1",
|
|
28
28
|
"sitemap": "^7.1.1",
|
|
29
29
|
"tslib": "^2.6.0"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=20.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "27626cdd7a102277935f10cc4d8d3f93e211eafe"
|
|
42
42
|
}
|
package/src/createSitemapItem.ts
CHANGED
|
@@ -6,16 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {applyTrailingSlash} from '@docusaurus/utils-common';
|
|
9
|
-
import {
|
|
9
|
+
import {normalizeUrl} from '@docusaurus/utils';
|
|
10
10
|
import type {LastModOption, SitemapItem} from './types';
|
|
11
|
-
import type {DocusaurusConfig, RouteConfig} from '@docusaurus/types';
|
|
11
|
+
import type {DocusaurusConfig, RouteConfig, VcsConfig} from '@docusaurus/types';
|
|
12
12
|
import type {PluginOptions} from './options';
|
|
13
13
|
|
|
14
14
|
async function getRouteLastUpdatedAt(
|
|
15
15
|
route: RouteConfig,
|
|
16
|
+
vcs: Pick<VcsConfig, 'getFileLastUpdateInfo'>,
|
|
16
17
|
): Promise<number | null | undefined> {
|
|
17
18
|
// Important to bail-out early here
|
|
18
|
-
// This can lead to duplicated
|
|
19
|
+
// This can lead to duplicated VCS calls and performance problems
|
|
19
20
|
// See https://github.com/facebook/docusaurus/pull/11211
|
|
20
21
|
if (route.metadata?.lastUpdatedAt === null) {
|
|
21
22
|
return null;
|
|
@@ -24,8 +25,10 @@ async function getRouteLastUpdatedAt(
|
|
|
24
25
|
return route.metadata?.lastUpdatedAt;
|
|
25
26
|
}
|
|
26
27
|
if (route.metadata?.sourceFilePath) {
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const lastUpdateInfo = await vcs.getFileLastUpdateInfo(
|
|
29
|
+
route.metadata?.sourceFilePath,
|
|
30
|
+
);
|
|
31
|
+
return lastUpdateInfo?.timestamp ?? null;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
return undefined;
|
|
@@ -46,14 +49,16 @@ function formatLastmod(timestamp: number, lastmodOption: LastModOption) {
|
|
|
46
49
|
async function getRouteLastmod({
|
|
47
50
|
route,
|
|
48
51
|
lastmod,
|
|
52
|
+
vcs,
|
|
49
53
|
}: {
|
|
50
54
|
route: RouteConfig;
|
|
51
55
|
lastmod: LastModOption | null;
|
|
56
|
+
vcs: Pick<VcsConfig, 'getFileLastUpdateInfo'>;
|
|
52
57
|
}): Promise<string | null> {
|
|
53
58
|
if (lastmod === null) {
|
|
54
59
|
return null;
|
|
55
60
|
}
|
|
56
|
-
const lastUpdatedAt = (await getRouteLastUpdatedAt(route)) ?? null;
|
|
61
|
+
const lastUpdatedAt = (await getRouteLastUpdatedAt(route, vcs)) ?? null;
|
|
57
62
|
return lastUpdatedAt ? formatLastmod(lastUpdatedAt, lastmod) : null;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -77,6 +82,10 @@ export async function createSitemapItem({
|
|
|
77
82
|
]),
|
|
78
83
|
changefreq,
|
|
79
84
|
priority,
|
|
80
|
-
lastmod: await getRouteLastmod({
|
|
85
|
+
lastmod: await getRouteLastmod({
|
|
86
|
+
route,
|
|
87
|
+
lastmod,
|
|
88
|
+
vcs: siteConfig.future.experimental_vcs,
|
|
89
|
+
}),
|
|
81
90
|
};
|
|
82
91
|
}
|