@docusaurus/plugin-sitemap 3.9.1 → 3.9.2-alpha.0-canary-6548

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.
@@ -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 getLastUpdate() calls and performance problems
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 lastUpdate = await (0, utils_1.getLastUpdate)(route.metadata?.sourceFilePath);
24
- return lastUpdate?.lastUpdatedAt ?? null;
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({ route, lastmod }),
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.1",
3
+ "version": "3.9.2-alpha.0-canary-6548",
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.1",
22
- "@docusaurus/logger": "3.9.1",
23
- "@docusaurus/types": "3.9.1",
24
- "@docusaurus/utils": "3.9.1",
25
- "@docusaurus/utils-common": "3.9.1",
26
- "@docusaurus/utils-validation": "3.9.1",
21
+ "@docusaurus/core": "3.9.2-alpha.0-canary-6548",
22
+ "@docusaurus/logger": "3.9.2-alpha.0-canary-6548",
23
+ "@docusaurus/types": "3.9.2-alpha.0-canary-6548",
24
+ "@docusaurus/utils": "3.9.2-alpha.0-canary-6548",
25
+ "@docusaurus/utils-common": "3.9.2-alpha.0-canary-6548",
26
+ "@docusaurus/utils-validation": "3.9.2-alpha.0-canary-6548",
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": "c0dd59f0e712f85b6053c59e46b0514b5d2d1414"
41
+ "gitHead": "7694572787296be09b95c6ff0a541ae19185a9f5"
42
42
  }
@@ -6,16 +6,17 @@
6
6
  */
7
7
 
8
8
  import {applyTrailingSlash} from '@docusaurus/utils-common';
9
- import {getLastUpdate, normalizeUrl} from '@docusaurus/utils';
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 getLastUpdate() calls and performance problems
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 lastUpdate = await getLastUpdate(route.metadata?.sourceFilePath);
28
- return lastUpdate?.lastUpdatedAt ?? null;
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({route, lastmod}),
85
+ lastmod: await getRouteLastmod({
86
+ route,
87
+ lastmod,
88
+ vcs: siteConfig.future.experimental_vcs,
89
+ }),
81
90
  };
82
91
  }