@nuxtjs/sitemap 5.2.2 → 5.3.1

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.
Files changed (42) hide show
  1. package/dist/client/200.html +18 -13
  2. package/dist/client/404.html +18 -13
  3. package/dist/client/_nuxt/B474tPdy.js +66 -0
  4. package/dist/client/_nuxt/Buoqr_Oi.js +2 -0
  5. package/dist/client/_nuxt/{DCjyzNN-.js → D4FSFK-1.js} +1 -1
  6. package/dist/client/_nuxt/{o8H-iTt6.js → DG8tVHNj.js} +1 -1
  7. package/dist/client/_nuxt/DIdLHJDO.js +6 -0
  8. package/dist/client/_nuxt/DVC_qXWv.js +1 -0
  9. package/dist/client/_nuxt/{NL97_oaV.js → GPY1wEXZ.js} +1 -1
  10. package/dist/client/_nuxt/{BC6uB4eG.js → NFxtlGJv.js} +1 -1
  11. package/dist/client/_nuxt/{CL-qhHZf.js → TWpUoTs4.js} +1 -1
  12. package/dist/client/_nuxt/VQMr7AbF.js +1 -0
  13. package/dist/client/_nuxt/builds/latest.json +1 -1
  14. package/dist/client/_nuxt/builds/meta/5aa5f74e-5417-4c3c-b4b9-bb359c29ac03.json +1 -0
  15. package/dist/client/_nuxt/cW9vKj3g.js +1 -0
  16. package/dist/client/_nuxt/{entry.CmimZAHN.css → entry.CfxF9LiM.css} +1 -1
  17. package/dist/client/_nuxt/error-404.DU6HmMxi.css +1 -0
  18. package/dist/client/_nuxt/error-500.C9Y1G92M.css +1 -0
  19. package/dist/client/_nuxt/xiybaa_L.js +31 -0
  20. package/dist/client/index.html +18 -13
  21. package/dist/module.json +2 -2
  22. package/dist/module.mjs +119 -20
  23. package/dist/runtime/nitro/composables/defineSitemapEventHandler.d.ts +2 -1
  24. package/dist/runtime/nitro/plugins/nuxt-content.js +9 -1
  25. package/dist/runtime/nitro/routes/__sitemap__/debug.d.ts +1 -0
  26. package/dist/runtime/nitro/routes/sitemap.xml.js +1 -1
  27. package/dist/runtime/nitro/routes/sitemap.xsl.js +1 -1
  28. package/dist/runtime/nitro/sitemap/nitro.d.ts +1 -1
  29. package/dist/runtime/nitro/sitemap/nitro.js +1 -1
  30. package/dist/runtime/nitro/sitemap/urlset/sources.d.ts +1 -1
  31. package/dist/runtime/types.d.ts +7 -1
  32. package/package.json +18 -13
  33. package/dist/client/_nuxt/BGZ4JUW7.js +0 -31
  34. package/dist/client/_nuxt/BT6Hj2kT.js +0 -1
  35. package/dist/client/_nuxt/BnWyG0Yo.js +0 -1
  36. package/dist/client/_nuxt/CZ99H4LZ.js +0 -1
  37. package/dist/client/_nuxt/CoEqzGFw.js +0 -44
  38. package/dist/client/_nuxt/Icon.BhjmZGan.css +0 -1
  39. package/dist/client/_nuxt/IconCSS.BPON9v2Q.css +0 -1
  40. package/dist/client/_nuxt/builds/meta/db4ce94a-4eca-43d4-b5fb-da1dfa0d2a79.json +0 -1
  41. package/dist/client/_nuxt/error-404.C7lYlUVC.css +0 -1
  42. package/dist/client/_nuxt/error-500.f8GAwExH.css +0 -1
@@ -1,7 +1,8 @@
1
1
  <!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1">
3
- <link rel="stylesheet" href="/__sitemap__/devtools/_nuxt/entry.CmimZAHN.css">
4
- <link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BGZ4JUW7.js">
3
+ <link rel="stylesheet" href="/__sitemap__/devtools/_nuxt/entry.CfxF9LiM.css">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/xiybaa_L.js">
5
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DIdLHJDO.js">
5
6
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DXFkqnOI.js">
6
7
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BigF1UXR.js">
7
8
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CowR2XfX.js">
@@ -84,6 +85,8 @@
84
85
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DsfXcHUZ.js">
85
86
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/D71BffLY.js">
86
87
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Eh5U-gDp.js">
88
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DVC_qXWv.js">
89
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BR6CMsBL.js">
87
90
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BEjL32p1.js">
88
91
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/ChMCFiS0.js">
89
92
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/C6XIsc4F.js">
@@ -93,9 +96,9 @@
93
96
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/D6pmzCqS.js">
94
97
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Djqq6n-7.js">
95
98
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BdfWgkoX.js">
96
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/NL97_oaV.js">
99
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/GPY1wEXZ.js">
97
100
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/B_SUYfiV.js">
98
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CoEqzGFw.js">
101
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/B474tPdy.js">
99
102
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DAfrLhwG.js">
100
103
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DjTlIhuc.js">
101
104
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DAVo6uMX.js">
@@ -112,7 +115,6 @@
112
115
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CpAANOdC.js">
113
116
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DZqG9GXz.js">
114
117
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DmDrTTlz.js">
115
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BR6CMsBL.js">
116
118
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CqYeW6XZ.js">
117
119
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CiRxTSAc.js">
118
120
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/C3qJFuQy.js">
@@ -131,6 +133,7 @@
131
133
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Dg0DGYq4.js">
132
134
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Ksn5IXup.js">
133
135
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DdacRhvC.js">
136
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/VQMr7AbF.js">
134
137
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DGDuLtS6.js">
135
138
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Btshr8M_.js">
136
139
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CcYwH0AH.js">
@@ -185,6 +188,7 @@
185
188
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CuJfdYLG.js">
186
189
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BxwAa5i0.js">
187
190
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/C_8Fx7bH.js">
191
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Buoqr_Oi.js">
188
192
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DBeuZS66.js">
189
193
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DnLUQrgA.js">
190
194
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BacI6-DX.js">
@@ -196,8 +200,8 @@
196
200
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DVfdqzEq.js">
197
201
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/QZ3jNtnE.js">
198
202
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BLluXI4E.js">
199
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/o8H-iTt6.js">
200
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DCjyzNN-.js">
203
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/DG8tVHNj.js">
204
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/D4FSFK-1.js">
201
205
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/o-cPXEvd.js">
202
206
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Cicx_DS6.js">
203
207
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/D3VXSfF0.js">
@@ -224,6 +228,7 @@
224
228
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CRlnGVMD.js">
225
229
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/UREJT2Bw.js">
226
230
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CZZ6oYdA.js">
231
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/cW9vKj3g.js">
227
232
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BsvsQ1iS.js">
228
233
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/B2BuIiKK.js">
229
234
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BrGg7AAd.js">
@@ -253,9 +258,9 @@
253
258
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/B3g-KkBK.js">
254
259
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Bxkoe-BC.js">
255
260
  <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/Br6ll-O0.js">
256
- <link rel="prefetch" as="style" href="/__sitemap__/devtools/_nuxt/error-404.C7lYlUVC.css">
257
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BC6uB4eG.js">
258
- <link rel="prefetch" as="style" href="/__sitemap__/devtools/_nuxt/error-500.f8GAwExH.css">
259
- <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/CL-qhHZf.js">
260
- <script type="module" src="/__sitemap__/devtools/_nuxt/BGZ4JUW7.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
261
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__sitemap__/devtools",buildId:"db4ce94a-4eca-43d4-b5fb-da1dfa0d2a79",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
261
+ <link rel="prefetch" as="style" href="/__sitemap__/devtools/_nuxt/error-404.DU6HmMxi.css">
262
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/NFxtlGJv.js">
263
+ <link rel="prefetch" as="style" href="/__sitemap__/devtools/_nuxt/error-500.C9Y1G92M.css">
264
+ <link rel="prefetch" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/TWpUoTs4.js">
265
+ <script type="module" src="/__sitemap__/devtools/_nuxt/xiybaa_L.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
266
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__sitemap__/devtools",buildId:"5aa5f74e-5417-4c3c-b4b9-bb359c29ac03",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.json CHANGED
@@ -5,9 +5,9 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "sitemap",
8
- "version": "5.2.1",
8
+ "version": "5.3.0",
9
9
  "builder": {
10
- "@nuxt/module-builder": "0.8.0",
10
+ "@nuxt/module-builder": "0.8.1",
11
11
  "unbuild": "2.0.0"
12
12
  }
13
13
  }
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useNuxt, loadNuxtModuleInstance, createResolver, addTemplate, extendPages, defineNuxtModule, useLogger, hasNuxtModule, getNuxtModuleVersion, hasNuxtModuleCompatibility, addServerImports, addServerPlugin, addServerHandler, findPath, addPrerenderRoutes } from '@nuxt/kit';
2
- import { parseURL, withBase, joinURL, withoutLeadingSlash } from 'ufo';
2
+ import { withHttps, withBase, parseURL, joinURL, withoutLeadingSlash } from 'ufo';
3
3
  import { assertSiteConfig, installNuxtSiteConfig } from 'nuxt-site-config-kit';
4
4
  import { defu } from 'defu';
5
5
  import { readPackageJSON } from 'pkg-types';
@@ -14,10 +14,17 @@ import { build } from 'nitropack';
14
14
  import { withSiteUrl } from 'nuxt-site-config-kit/urls';
15
15
  import { normaliseDate } from '../dist/runtime/nitro/sitemap/urlset/normalise.js';
16
16
 
17
- async function resolveUrls(urls) {
17
+ async function resolveUrls(urls, ctx) {
18
18
  if (typeof urls === "function")
19
19
  urls = urls();
20
20
  urls = await urls;
21
+ try {
22
+ urls = JSON.parse(JSON.stringify(urls));
23
+ } catch (e) {
24
+ ctx.logger.warn(`Failed to serialize ${typeof urls} \`${ctx.path}\`, please make sure that the urls resolve as a valid array without circular dependencies.`);
25
+ ctx.logger.error(e);
26
+ return [];
27
+ }
21
28
  return urls;
22
29
  }
23
30
  function deepForEachPage(pages, callback, fullpath = null, depth = 0) {
@@ -50,6 +57,15 @@ function convertNuxtPagesToSitemapEntries(pages, config) {
50
57
  delete p.depth;
51
58
  return p;
52
59
  });
60
+ if (config.strategy === "prefix_and_default") {
61
+ flattenedPages = flattenedPages.filter((p) => {
62
+ if (p.page?.name) {
63
+ const [, locale] = p.page.name.split(routesNameSeparator);
64
+ return locale !== config.defaultLocale || p.page.name.endsWith("__default");
65
+ }
66
+ return true;
67
+ });
68
+ }
53
69
  const pagesWithMeta = flattenedPages.map((p) => {
54
70
  if (config.autoLastmod && p.page.file) {
55
71
  try {
@@ -94,19 +110,23 @@ function convertNuxtPagesToSitemapEntries(pages, config) {
94
110
  }
95
111
  return entries.map((entry) => {
96
112
  const alternatives = entries.map((entry2) => {
97
- const hreflang = config.normalisedLocales.find((l) => l.code === entry2.locale)?.iso || entry2.locale;
113
+ const locale2 = config.normalisedLocales.find((l) => l.code === entry2.locale);
114
+ const hreflang = locale2?.iso || entry2.locale;
98
115
  if (!pathFilter(entry2.loc))
99
116
  return false;
117
+ const href = locale2?.domain ? withHttps(withBase(entry2.loc, locale2?.domain)) : entry2.loc;
100
118
  return {
101
119
  hreflang,
102
- href: entry2.loc
120
+ href
103
121
  };
104
122
  }).filter(Boolean);
105
123
  const xDefault = entries.find((a) => a.locale === config.defaultLocale);
106
- if (xDefault && alternatives.length) {
124
+ if (xDefault && alternatives.length && pathFilter(xDefault.loc)) {
125
+ const locale2 = config.normalisedLocales.find((l) => l.code === xDefault.locale);
126
+ const href = locale2?.domain ? withHttps(withBase(xDefault.loc, locale2?.domain)) : xDefault.loc;
107
127
  alternatives.push({
108
128
  hreflang: "x-default",
109
- href: xDefault.loc
129
+ href
110
130
  });
111
131
  }
112
132
  const e = { ...entry };
@@ -222,7 +242,7 @@ function resolveNitroPreset(nitroConfig) {
222
242
  }
223
243
 
224
244
  function extractSitemapMetaFromHtml(html, options) {
225
- options = options || { images: true, lastmod: true, alternatives: true };
245
+ options = options || { images: true, videos: true, lastmod: true, alternatives: true };
226
246
  const payload = {};
227
247
  if (options?.images) {
228
248
  const images = /* @__PURE__ */ new Set();
@@ -243,6 +263,61 @@ function extractSitemapMetaFromHtml(html, options) {
243
263
  if (images.size > 0)
244
264
  payload.images = [...images].map((i) => ({ loc: i }));
245
265
  }
266
+ if (options?.videos) {
267
+ const videos = [];
268
+ const mainRegex = /<main[^>]*>([\s\S]*?)<\/main>/;
269
+ const mainMatch = mainRegex.exec(html);
270
+ if (mainMatch?.[1] && mainMatch[1].includes("<video")) {
271
+ const videoRegex = /<video[^>]*>([\s\S]*?)<\/video>/g;
272
+ const videoAttrRegex = /<video[^>]*\ssrc="([^"]+)"(?:[^>]*\sposter="([^"]+)")?/;
273
+ const videoPosterRegex = /<video[^>]*\sposter="([^"]+)"/;
274
+ const videoTitleRegex = /<video[^>]*\sdata-title="([^"]+)"/;
275
+ const videoDescriptionRegex = /<video[^>]*\sdata-description="([^"]+)"/;
276
+ const sourceRegex = /<source[^>]*\ssrc="([^"]+)"/g;
277
+ let videoMatch;
278
+ while ((videoMatch = videoRegex.exec(mainMatch[1])) !== null) {
279
+ const videoContent = videoMatch[1];
280
+ const videoTag = videoMatch[0];
281
+ const videoAttrMatch = videoAttrRegex.exec(videoTag);
282
+ const videoSrc = videoAttrMatch ? videoAttrMatch[1] : "";
283
+ const poster = (videoPosterRegex.exec(videoTag) || [])[1] || "";
284
+ const title = (videoTitleRegex.exec(videoTag) || [])[1] || "";
285
+ const description = (videoDescriptionRegex.exec(videoTag) || [])[1] || "";
286
+ const sources = [];
287
+ let sourceMatch;
288
+ while ((sourceMatch = sourceRegex.exec(videoContent)) !== null) {
289
+ sources.push({
290
+ src: sourceMatch[1],
291
+ poster,
292
+ title,
293
+ description
294
+ });
295
+ }
296
+ if (videoSrc) {
297
+ videos.push({
298
+ src: videoSrc,
299
+ poster,
300
+ title,
301
+ description,
302
+ sources: []
303
+ });
304
+ }
305
+ if (sources.length > 0) {
306
+ videos.push(...sources);
307
+ }
308
+ }
309
+ }
310
+ if (videos.length > 0) {
311
+ payload.videos = videos.map(
312
+ (video) => ({
313
+ content_loc: video.src,
314
+ thumbnail_loc: video.poster,
315
+ title: video.title,
316
+ description: video.description
317
+ })
318
+ );
319
+ }
320
+ }
246
321
  if (options?.lastmod) {
247
322
  const articleModifiedTime = html.match(/<meta[^>]+property="article:modified_time"[^>]+content="([^"]+)"/)?.[1] || html.match(/<meta[^>]+content="([^"]+)"[^>]+property="article:modified_time"/)?.[1];
248
323
  if (articleModifiedTime)
@@ -274,7 +349,10 @@ function includesSitemapRoot(sitemapName, routes) {
274
349
  return routes.includes(`/sitemap.xml`) || routes.includes(`/${sitemapName}`) || routes.includes("/sitemap_index.xml");
275
350
  }
276
351
  function isNuxtGenerate(nuxt = useNuxt()) {
277
- return nuxt.options._generate || nuxt.options.nitro.static || nuxt.options.nitro.preset === "static";
352
+ return nuxt.options._generate || [
353
+ "static",
354
+ "github-pages"
355
+ ].includes(resolveNitroPreset());
278
356
  }
279
357
  function setupPrerenderHandler(options, nuxt = useNuxt()) {
280
358
  const prerenderedRoutes = nuxt.options.nitro.prerender?.routes || [];
@@ -307,6 +385,7 @@ function setupPrerenderHandler(options, nuxt = useNuxt()) {
307
385
  }
308
386
  route._sitemap = defu(extractSitemapMetaFromHtml(html, {
309
387
  images: options.discoverImages,
388
+ videos: options.discoverVideos,
310
389
  // TODO configurable?
311
390
  lastmod: true,
312
391
  alternatives: true
@@ -412,17 +491,20 @@ function splitPathForI18nLocales(path, autoI18n) {
412
491
  ...locales.map((l) => `/${l.code}${path}`)
413
492
  ];
414
493
  }
415
- function generatePathForI18nPages({ localeCode, pageLocales, nuxtI18nConfig, forcedStrategy }) {
494
+ function generatePathForI18nPages(ctx) {
495
+ const { localeCode, pageLocales, nuxtI18nConfig, forcedStrategy, normalisedLocales } = ctx;
496
+ const locale = normalisedLocales.find((l) => l.code === localeCode);
497
+ let path = pageLocales;
416
498
  switch (forcedStrategy ?? nuxtI18nConfig.strategy) {
417
499
  case "prefix_except_default":
418
500
  case "prefix_and_default":
419
- return localeCode === nuxtI18nConfig.defaultLocale ? pageLocales : joinURL(localeCode, pageLocales);
501
+ path = localeCode === nuxtI18nConfig.defaultLocale ? pageLocales : joinURL(localeCode, pageLocales);
502
+ break;
420
503
  case "prefix":
421
- return joinURL(localeCode, pageLocales);
422
- case "no_prefix":
423
- default:
424
- return pageLocales;
504
+ path = joinURL(localeCode, pageLocales);
505
+ break;
425
506
  }
507
+ return locale?.domain ? withHttps(withBase(path, locale.domain)) : path;
426
508
  }
427
509
 
428
510
  function isValidFilter(filter) {
@@ -462,6 +544,7 @@ const module = defineNuxtModule({
462
544
  defaultSitemapsChunkSize: 1e3,
463
545
  autoLastmod: false,
464
546
  discoverImages: true,
547
+ discoverVideos: true,
465
548
  dynamicUrlsApiEndpoint: "/api/_sitemap-urls",
466
549
  urls: [],
467
550
  sortEntries: true,
@@ -505,6 +588,18 @@ const module = defineNuxtModule({
505
588
  config.defaults = config.defaults || {};
506
589
  config.defaults.lastmod = normaliseDate(/* @__PURE__ */ new Date());
507
590
  }
591
+ if (!nuxt.options._prepare && Object.keys(config.sitemaps || {}).length) {
592
+ const invalidRootKeys = [
593
+ "includeAppSources",
594
+ "sources"
595
+ ];
596
+ for (const key of invalidRootKeys) {
597
+ if (Object.keys(config).includes(key)) {
598
+ logger.warn(`You are using multiple-sitemaps but have provided \`sitemap.${key}\` in your Nuxt config. This will be ignored, please move it to the child sitemap config.`);
599
+ logger.warn("Learn more at: https://nuxtseo.com/sitemap/guides/multi-sitemaps");
600
+ }
601
+ }
602
+ }
508
603
  await installNuxtSiteConfig();
509
604
  const userGlobalSources = [
510
605
  ...config.sources || []
@@ -550,19 +645,19 @@ const module = defineNuxtModule({
550
645
  continue;
551
646
  const alternatives = Object.keys(pageLocales).map((l) => ({
552
647
  hreflang: normalisedLocales.find((nl) => nl.code === l)?.iso || l,
553
- href: generatePathForI18nPages({ localeCode: l, pageLocales: pageLocales[l], nuxtI18nConfig })
648
+ href: generatePathForI18nPages({ localeCode: l, pageLocales: pageLocales[l], nuxtI18nConfig, normalisedLocales })
554
649
  }));
555
650
  if (alternatives.length && nuxtI18nConfig.defaultLocale && pageLocales[nuxtI18nConfig.defaultLocale])
556
- alternatives.push({ hreflang: "x-default", href: generatePathForI18nPages({ localeCode: nuxtI18nConfig.defaultLocale, pageLocales: pageLocales[nuxtI18nConfig.defaultLocale], nuxtI18nConfig }) });
651
+ alternatives.push({ hreflang: "x-default", href: generatePathForI18nPages({ normalisedLocales, localeCode: nuxtI18nConfig.defaultLocale, pageLocales: pageLocales[nuxtI18nConfig.defaultLocale], nuxtI18nConfig }) });
557
652
  i18nPagesSources.urls.push({
558
653
  _sitemap: locale.iso || locale.code,
559
- loc: generatePathForI18nPages({ localeCode, pageLocales: pageLocales[localeCode], nuxtI18nConfig }),
654
+ loc: generatePathForI18nPages({ normalisedLocales, localeCode, pageLocales: pageLocales[localeCode], nuxtI18nConfig }),
560
655
  alternatives
561
656
  });
562
657
  if (nuxtI18nConfig.strategy === "prefix_and_default" && localeCode === nuxtI18nConfig.defaultLocale) {
563
658
  i18nPagesSources.urls.push({
564
659
  _sitemap: locale.iso || locale.code,
565
- loc: generatePathForI18nPages({ localeCode, pageLocales: pageLocales[localeCode], nuxtI18nConfig, forcedStrategy: "prefix" }),
660
+ loc: generatePathForI18nPages({ normalisedLocales, localeCode, pageLocales: pageLocales[localeCode], nuxtI18nConfig, forcedStrategy: "prefix" }),
566
661
  alternatives
567
662
  });
568
663
  }
@@ -808,6 +903,7 @@ declare module 'vue-router' {
808
903
  debug: config.debug,
809
904
  // needed for nuxt/content integration and prerendering
810
905
  discoverImages: config.discoverImages,
906
+ discoverVideos: config.discoverVideos,
811
907
  /* @nuxt/content */
812
908
  isNuxtContentDocumentDriven,
813
909
  /* xsl styling */
@@ -866,13 +962,16 @@ declare module 'vue-router' {
866
962
  exclude: normalizeFilters(config.exclude)
867
963
  }
868
964
  });
965
+ if (!pageSource.length) {
966
+ pageSource.push(nuxt.options.app.baseURL || "/");
967
+ }
869
968
  if (!resolvedConfigUrls) {
870
969
  config.urls && userGlobalSources.push({
871
970
  context: {
872
971
  name: "sitemap:urls",
873
972
  description: "Set with the `sitemap.urls` config."
874
973
  },
875
- urls: await resolveUrls(config.urls)
974
+ urls: await resolveUrls(config.urls, { path: "sitemap:urls", logger })
876
975
  });
877
976
  resolvedConfigUrls = true;
878
977
  }
@@ -938,7 +1037,7 @@ declare module 'vue-router' {
938
1037
  name: `sitemaps:${sitemapName}:urls`,
939
1038
  description: "Set with the `sitemap.urls` config."
940
1039
  },
941
- urls: await resolveUrls(definition.urls)
1040
+ urls: await resolveUrls(definition.urls, { path: `sitemaps:${sitemapName}:urls`, logger })
942
1041
  });
943
1042
  definition.dynamicUrlsApiEndpoint && sitemapSources[sitemapName].push({
944
1043
  context: {
@@ -1,3 +1,4 @@
1
- import { type EventHandlerRequest, type EventHandlerResponse, defineEventHandler } from 'h3';
1
+ import { defineEventHandler } from 'h3';
2
+ import type { EventHandlerRequest, EventHandlerResponse } from 'h3';
2
3
  import type { SitemapUrlInput } from '../../types.js';
3
4
  export declare const defineSitemapEventHandler: typeof defineEventHandler<EventHandlerRequest, EventHandlerResponse<SitemapUrlInput[]>>;
@@ -2,7 +2,7 @@ import { defu } from "defu";
2
2
  import { useSimpleSitemapRuntimeConfig } from "../utils.js";
3
3
  import { defineNitroPlugin } from "#imports";
4
4
  export default defineNitroPlugin((nitroApp) => {
5
- const { discoverImages, isNuxtContentDocumentDriven } = useSimpleSitemapRuntimeConfig();
5
+ const { discoverImages, discoverVideos, isNuxtContentDocumentDriven } = useSimpleSitemapRuntimeConfig();
6
6
  nitroApp.hooks.hook("content:file:afterParse", async (content) => {
7
7
  const validExtensions = ["md", "mdx"];
8
8
  if (content.sitemap === false || content._draft || !validExtensions.includes(content._extension) || content._partial || content.indexable === false || content.index === false)
@@ -13,6 +13,12 @@ export default defineNitroPlugin((nitroApp) => {
13
13
  (c) => c.tag && c.props?.src && ["image", "img", "nuxtimg", "nuxt-img"].includes(c.tag.toLowerCase())
14
14
  ).map((i) => ({ loc: i.props.src })) || [];
15
15
  }
16
+ let videos = [];
17
+ if (discoverVideos) {
18
+ videos = content.body?.children?.filter(
19
+ (c) => c.tag && c.props?.src && ["video"].includes(c.tag.toLowerCase())
20
+ ).map((i) => ({ content_loc: i.props.src })) || [];
21
+ }
16
22
  const sitemapConfig = typeof content.sitemap === "object" ? content.sitemap : {};
17
23
  const lastmod = content.modifiedAt || content.updatedAt;
18
24
  const defaults = {};
@@ -22,6 +28,8 @@ export default defineNitroPlugin((nitroApp) => {
22
28
  defaults.loc = content.path;
23
29
  if (images.length > 0)
24
30
  defaults.images = images;
31
+ if (videos.length > 0)
32
+ defaults.videos = videos;
25
33
  if (lastmod)
26
34
  defaults.lastmod = lastmod;
27
35
  const definition = defu(sitemapConfig, defaults);
@@ -28,6 +28,7 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
28
28
  xslTips: boolean;
29
29
  debug: boolean;
30
30
  discoverImages: boolean;
31
+ discoverVideos: boolean;
31
32
  autoLastmod: boolean;
32
33
  xsl: string | false;
33
34
  credits: boolean;
@@ -7,7 +7,7 @@ export default defineEventHandler(async (e) => {
7
7
  const runtimeConfig = useSimpleSitemapRuntimeConfig();
8
8
  const { sitemaps } = runtimeConfig;
9
9
  if ("index" in sitemaps) {
10
- return sendRedirect(e, withBase("/sitemap_index.xml", useRuntimeConfig().app.baseURL), process.dev ? 302 : 301);
10
+ return sendRedirect(e, withBase("/sitemap_index.xml", useRuntimeConfig().app.baseURL), import.meta.dev ? 302 : 301);
11
11
  }
12
12
  return createSitemap(e, Object.values(sitemaps)[0], runtimeConfig);
13
13
  });
@@ -31,7 +31,7 @@ export default defineEventHandler(async (e) => {
31
31
  conditionalTips.push(`You are viewing the canonical sitemap. You can switch to using the request origin: <a href="${fixPath(referrer)}" style="color: #398465; white-space: nowrap ">${fixPath(referrer)}</a>`);
32
32
  }
33
33
  const tips = conditionalTips.map((t) => `<li><p>${t}</p></li>`).join("\n");
34
- const showTips = process.dev && xslTips !== false;
34
+ const showTips = import.meta.dev && xslTips !== false;
35
35
  let columns = [...xslColumns];
36
36
  if (!columns.length) {
37
37
  columns = [
@@ -1,4 +1,4 @@
1
- import { type H3Event } from 'h3';
1
+ import type { H3Event } from 'h3';
2
2
  import type { ModuleRuntimeConfig, NitroUrlResolvers, SitemapDefinition } from '../../types.js';
3
3
  export declare function useNitroUrlResolvers(e: H3Event): NitroUrlResolvers;
4
4
  export declare function createSitemap(e: H3Event, definition: SitemapDefinition, runtimeConfig: ModuleRuntimeConfig): Promise<string>;
@@ -12,7 +12,7 @@ export function useNitroUrlResolvers(e) {
12
12
  fixSlashes: (path) => fixSlashes(siteConfig.trailingSlash, path),
13
13
  // we need these as they depend on the nitro event
14
14
  canonicalUrlResolver: createSitePathResolver(e, {
15
- canonical: isShowingCanonical || !process.dev,
15
+ canonical: isShowingCanonical || !import.meta.dev,
16
16
  absolute: true,
17
17
  withBase: true
18
18
  }),
@@ -1,4 +1,4 @@
1
- import { type H3Event } from 'h3';
1
+ import type { H3Event } from 'h3';
2
2
  import type { ModuleRuntimeConfig, SitemapSourceBase, SitemapSourceResolved } from '../../../types.js';
3
3
  export declare function fetchDataSource(input: SitemapSourceBase | SitemapSourceResolved, event?: H3Event): Promise<SitemapSourceResolved>;
4
4
  export declare function globalSitemapSources(): Promise<(SitemapSourceBase | SitemapSourceResolved)[]>;
@@ -75,6 +75,12 @@ export interface ModuleOptions extends SitemapDefinition {
75
75
  * @default true
76
76
  */
77
77
  discoverImages: boolean;
78
+ /**
79
+ * When prerendering, should videos be automatically be discovered and added to the sitemap.
80
+ *
81
+ * @default true
82
+ */
83
+ discoverVideos: boolean;
78
84
  /**
79
85
  * When chunking the sitemaps into multiple files, how many entries should each file contain.
80
86
  *
@@ -187,7 +193,7 @@ export interface AutoI18nConfig {
187
193
  defaultLocale: string;
188
194
  strategy: 'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix';
189
195
  }
190
- export interface ModuleRuntimeConfig extends Pick<ModuleOptions, 'cacheMaxAgeSeconds' | 'sitemapName' | 'excludeAppSources' | 'sortEntries' | 'defaultSitemapsChunkSize' | 'xslColumns' | 'xslTips' | 'debug' | 'discoverImages' | 'autoLastmod' | 'xsl' | 'credits'> {
196
+ export interface ModuleRuntimeConfig extends Pick<ModuleOptions, 'cacheMaxAgeSeconds' | 'sitemapName' | 'excludeAppSources' | 'sortEntries' | 'defaultSitemapsChunkSize' | 'xslColumns' | 'xslTips' | 'debug' | 'discoverImages' | 'discoverVideos' | 'autoLastmod' | 'xsl' | 'credits'> {
191
197
  version: string;
192
198
  isNuxtContentDocumentDriven: boolean;
193
199
  sitemaps: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/sitemap",
3
3
  "type": "module",
4
- "version": "5.2.2",
4
+ "version": "5.3.1",
5
5
  "description": "Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -18,6 +18,9 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/nuxt-modules/sitemap/issues"
20
20
  },
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
21
24
  "exports": {
22
25
  ".": {
23
26
  "types": "./dist/types.d.ts",
@@ -31,8 +34,8 @@
31
34
  "dist"
32
35
  ],
33
36
  "dependencies": {
34
- "@nuxt/devtools-kit": "^1.3.6",
35
- "@nuxt/devtools-ui-kit": "^1.3.6",
37
+ "@nuxt/devtools-kit": "^1.3.7",
38
+ "@nuxt/devtools-ui-kit": "^1.3.7",
36
39
  "@nuxt/kit": "^3.12.2",
37
40
  "@vueuse/core": "^10.11.0",
38
41
  "chalk": "^5.3.0",
@@ -46,26 +49,26 @@
46
49
  "pkg-types": "^1.1.1",
47
50
  "radix3": "^1.1.2",
48
51
  "semver": "^7.6.2",
49
- "shiki": "1.9.0",
52
+ "shiki": "1.10.0",
50
53
  "sirv": "^2.0.4",
51
54
  "site-config-stack": "^2.2.12",
52
55
  "ufo": "^1.5.3"
53
56
  },
54
57
  "devDependencies": {
55
- "@antfu/eslint-config": "^2.21.1",
56
58
  "@nuxt/content": "^2.13.0",
59
+ "@nuxt/eslint-config": "^0.3.13",
57
60
  "@nuxt/kit": "^3.12.2",
58
- "@nuxt/module-builder": "0.8.0",
61
+ "@nuxt/module-builder": "0.8.1",
59
62
  "@nuxt/test-utils": "^3.13.1",
60
63
  "@nuxt/ui": "^2.17.0",
61
- "@nuxtjs/eslint-config-typescript": "^12.1.0",
62
64
  "@nuxtjs/i18n": "8.3.1",
63
65
  "bumpp": "^9.4.1",
64
- "eslint": "9.5.0",
66
+ "eslint": "9.6.0",
67
+ "eslint-plugin-n": "^17.9.0",
65
68
  "execa": "^9.3.0",
66
69
  "nuxt": "^3.12.2",
67
- "nuxt-icon": "^0.6.10",
68
- "nuxt-simple-robots": "^4.0.0-rc.17",
70
+ "nuxt-icon": "1.0.0-beta.7",
71
+ "nuxt-simple-robots": "4.0.0-rc.19",
69
72
  "typescript": "5.4.5",
70
73
  "vitest": "^1.6.0"
71
74
  },
@@ -77,7 +80,9 @@
77
80
  ]
78
81
  },
79
82
  "scripts": {
80
- "lint": "eslint . --fix",
83
+ "lint": "eslint .",
84
+ "lint:type": "tsc --noEmit",
85
+ "lint:fix": "eslint . --fix",
81
86
  "client:build": "nuxi generate client",
82
87
  "client:dev": "nuxi dev client --port 3300",
83
88
  "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && npm run client:build",
@@ -86,7 +91,7 @@
86
91
  "dev:build": "nuxi build .playground",
87
92
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare .playground",
88
93
  "release": "pnpm build && bumpp && pnpm -r publish",
89
- "typecheck": "tsc --noEmit ",
90
- "test": "vitest"
94
+ "test": "vitest",
95
+ "postinstall": "pnpm dev:prepare"
91
96
  }
92
97
  }