@nuxtjs/sitemap 7.6.0 → 8.0.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 (143) hide show
  1. package/README.md +8 -2
  2. package/dist/content.d.mts +42 -69
  3. package/dist/content.d.ts +42 -69
  4. package/dist/content.mjs +57 -41
  5. package/dist/devtools/200.html +1 -0
  6. package/dist/devtools/404.html +1 -0
  7. package/dist/devtools/_fonts/4ppnHhMi-pBsWSPo7mY0avYxlDoAg1N3PTzCwXLZ5rA-d9oibkGnTd1JL3tc_xnaVgBLYmOB8kjrK2cvZaqwj9s.woff2 +0 -0
  8. package/dist/devtools/_fonts/4qBuU9MRVUlPZNPSF7Xom_sK8RBEnfYu-9VXFrdq8A8-8TDwLE1HAj1sQn7XxVWtM_7sIaPM-DTdO3Pf8U2DF1U.woff2 +0 -0
  9. package/dist/devtools/_fonts/6dYsbWUd_BpKJ7mdDihgOcya1gHXLpJBuMYXux3WMjE-q3fYNS8YbW5n7ZeXI2vSNgkRWW5VDPKAl51SNTjG2qk.woff2 +0 -0
  10. package/dist/devtools/_fonts/Lr-hqqZZsYmCt0ITUlr1CUrWim9fsKvoDFZliMxgNHY-iTa_Yt_PzhOY9TX7ZXdSlEPim6iRt92xhECwaxWxd5w.woff2 +0 -0
  11. package/dist/devtools/_fonts/OknHvWI6KtYn1JQBzX7eSpNDBQ8520F9TvSUJYkVf6A-xeZn9253svK_8Q2LD0XEruY_MnEsuCRO5LenPoggC0Y.woff2 +0 -0
  12. package/dist/devtools/_fonts/PV2hrQG6wq5BlIPDjdL1IcOflycaghyt5MHzlBqZtlo-lb_WexLz3VZqfTN0oi554iBH5tT2j2UFEV-XErCAS3E.woff2 +0 -0
  13. package/dist/devtools/_fonts/UA7OtwYHwGN_HjcVGTdmiQxUit7FlqkCwxVUWSeXVnQ-B4OXCFOL_tWrYODpQTc07aMaj0c2cewTOmBRWR9tD-A.woff2 +0 -0
  14. package/dist/devtools/_fonts/VE4cDVCv5MxbFM7ZLoLCGbIpNd71zhp7MDI9lmN5Y7I-xZyDYCUVrd6LV8eVGF3Um3UZjBFuUtDGtvdyTBBRYBo.woff2 +0 -0
  15. package/dist/devtools/_fonts/fVoGbnMbBFd5L9BBp9fUPavUSkZ_EmsQNSyadkT-108-U4T0khaeLQSIhtt9eVvaCEKJjtWJ4ioRJOf8hvqkWY0.woff2 +0 -0
  16. package/dist/devtools/_fonts/lQAxeCEs1R0Lw-H9XRU1RlOARQN8J6npRsPjyEDMe5s-_DUSLEkO3tKTuun_gSnDLoQPVEnpOnyqZMOw0ByZ6PA.woff2 +0 -0
  17. package/dist/devtools/_fonts/lntlqNHKLV2n82yTwMde70QqOjcfLE2XJ5oKZ3vRPWc-z6TxpIZQdWXztWLr9_OFWqt_WJJoeGtuK_-XQMZGQwE.woff2 +0 -0
  18. package/dist/devtools/_fonts/qxAYvKsXWeYv731eb-h5TRurcdIP_W44mpNdX-HABAk-zUDeMEFlNtNbrwvT9JxLEBg0TphGy70O6RfIoIX_ZwU.woff2 +0 -0
  19. package/dist/devtools/_nuxt/6-8YL5RT.js +1 -0
  20. package/dist/devtools/_nuxt/B-CoxLn7.js +1 -0
  21. package/dist/devtools/_nuxt/BBg_LgdD.js +1 -0
  22. package/dist/devtools/_nuxt/BFP26XjE.js +1 -0
  23. package/dist/devtools/_nuxt/BFxFqELk.js +1 -0
  24. package/dist/devtools/_nuxt/BJ46vUgN.js +22 -0
  25. package/dist/devtools/_nuxt/BK43-3Xm.js +1 -0
  26. package/dist/devtools/_nuxt/BUgp7PK5.js +1 -0
  27. package/dist/devtools/_nuxt/BUwCbG2W.js +1 -0
  28. package/dist/devtools/_nuxt/BgUkVPML.js +1 -0
  29. package/dist/devtools/_nuxt/Bl-ESRhh.js +1 -0
  30. package/dist/devtools/_nuxt/BpntLhpu.js +1 -0
  31. package/dist/devtools/_nuxt/CMkTWvG2.js +1 -0
  32. package/dist/devtools/_nuxt/CdSSkj0j.js +6 -0
  33. package/dist/devtools/_nuxt/Cfg7NvvP.js +3 -0
  34. package/dist/devtools/_nuxt/Cq2IBCZt.js +1 -0
  35. package/dist/devtools/_nuxt/D56-uEuD.js +1 -0
  36. package/dist/devtools/_nuxt/D9eL2h5z.js +1 -0
  37. package/dist/devtools/_nuxt/DC83McAa.js +154 -0
  38. package/dist/devtools/_nuxt/DLfyhkbV.js +1 -0
  39. package/dist/devtools/_nuxt/DRdBN13f.js +1 -0
  40. package/dist/devtools/_nuxt/DevtoolsEmptyState.CPam6VsX.css +1 -0
  41. package/dist/devtools/_nuxt/DevtoolsSection.BeqVO-za.css +1 -0
  42. package/dist/devtools/_nuxt/DuYBAn1h.js +1 -0
  43. package/dist/devtools/_nuxt/Source.ChvNXxeG.css +1 -0
  44. package/dist/devtools/_nuxt/_hKGTbzI.js +1 -0
  45. package/dist/devtools/_nuxt/builds/latest.json +1 -0
  46. package/dist/devtools/_nuxt/builds/meta/faabf89a-40de-433d-ae87-9f9d117398e4.json +1 -0
  47. package/dist/devtools/_nuxt/entry.DuwzcCXL.css +2 -0
  48. package/dist/devtools/_nuxt/error-404.CbnweSUu.css +1 -0
  49. package/dist/devtools/_nuxt/error-500.DrNDBqZi.css +1 -0
  50. package/dist/devtools/_nuxt/jxhrXVY1.js +1 -0
  51. package/dist/devtools/_nuxt/pages.CV7xHNff.css +1 -0
  52. package/dist/devtools/app-sources/index.html +1 -0
  53. package/dist/devtools/debug/index.html +1 -0
  54. package/dist/devtools/docs/index.html +1 -0
  55. package/dist/devtools/index.html +1 -0
  56. package/dist/devtools/user-sources/index.html +1 -0
  57. package/dist/module.d.mts +10 -1
  58. package/dist/module.d.ts +10 -1
  59. package/dist/module.json +1 -1
  60. package/dist/module.mjs +321 -430
  61. package/dist/runtime/server/composables/defineSitemapEventHandler.d.ts +1 -1
  62. package/dist/runtime/server/kit.d.ts +0 -1
  63. package/dist/runtime/server/kit.js +5 -7
  64. package/dist/runtime/server/plugins/warm-up.js +1 -1
  65. package/dist/runtime/server/robots-polyfill/getPathRobotConfig.d.ts +1 -1
  66. package/dist/runtime/server/robots-polyfill/getPathRobotConfig.js +1 -1
  67. package/dist/runtime/server/routes/__sitemap__/debug-production.d.ts +17 -0
  68. package/dist/runtime/server/routes/__sitemap__/debug-production.js +76 -0
  69. package/dist/runtime/server/routes/__sitemap__/debug.js +3 -3
  70. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.js +1 -1
  71. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.js +3 -3
  72. package/dist/runtime/server/routes/sitemap.xsl.js +4 -4
  73. package/dist/runtime/server/sitemap/builder/sitemap-index.js +8 -7
  74. package/dist/runtime/server/sitemap/builder/sitemap.d.ts +1 -1
  75. package/dist/runtime/server/sitemap/builder/sitemap.js +10 -8
  76. package/dist/runtime/server/sitemap/builder/xml.js +51 -25
  77. package/dist/runtime/server/sitemap/event-handlers.js +4 -4
  78. package/dist/runtime/server/sitemap/nitro.js +6 -6
  79. package/dist/runtime/server/sitemap/urlset/normalise.js +1 -1
  80. package/dist/runtime/server/sitemap/urlset/sources.js +2 -2
  81. package/dist/runtime/types.d.ts +5 -8
  82. package/dist/runtime/utils-pure.d.ts +3 -4
  83. package/dist/runtime/utils-pure.js +13 -41
  84. package/dist/shared/{sitemap.Bj0OAEtK.mjs → sitemap.B99ug6A9.mjs} +9 -5
  85. package/dist/utils.d.mts +9 -9
  86. package/dist/utils.d.ts +9 -9
  87. package/dist/utils.mjs +60 -59
  88. package/package.json +47 -46
  89. package/dist/client/200.html +0 -1
  90. package/dist/client/404.html +0 -1
  91. package/dist/client/_fonts/0xp3SbCWC1OhX7q1-uF6kilMZFm-alJNkUtkLTPCy_A-tN9KwPUWhhXvtqh74sU9FIkI4W6hsbm85r0X24hjOfM.woff2 +0 -0
  92. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-995OEiyou9G2dJsMNn9aLuHTFlgwosm_9gD5SQUWR40.woff +0 -0
  93. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-D6hedAgqRfOCLZzaShnyeAvlEnMzk4Wm7g9WDKWFHIc.woff +0 -0
  94. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-vrK12kZ24WGUghky9YxsOZpLH8Tt4jMU8XIvzgLQ6DU.woff +0 -0
  95. package/dist/client/_fonts/4HA9tc4y8BVQeLXvLn3JgQqilAj1xrAnUSprQGHIPSw-ZPswEL_UDOYaxTLQDUySPjoOHDxhD83pD19HMfKfK9s.woff2 +0 -0
  96. package/dist/client/_fonts/Bmul3LaKlc7BUKqJHE_UmEoF40Sg_2ga52yJjwyDcKs-TnYmYl1DNYkiWMu0Vx49DakCPBuiCCj9zoLIuQjUdKY.woff2 +0 -0
  97. package/dist/client/_fonts/DfgmjWGpWte3Q3a54Nevr_BYmMM5YEJXRI1CdI2VwO0-ox5RadQfCyVTmKl_hubTaIJjtRw9oaQz2GDBeZR6l1M.woff2 +0 -0
  98. package/dist/client/_fonts/LK8hREFNeTe-EIzvbfgusJBg3CJ7Q7NFgYIiGb2LZ8-qiyWl0ATLJjOsRPZC_7a8mTMFxEMKEv6JTK_kHtMzbM.woff2 +0 -0
  99. package/dist/client/_fonts/Lc_5lWuBuZcZ166p1-s-mnGkMJwIYJE_QDCkws8iCkI-r45Qbm2hCykrfOZ0kowz__uTTTUOPDN9hz34QcRNTY4.woff2 +0 -0
  100. package/dist/client/_fonts/UBlOS9e0BmJuiF5yVs0YcJrFWaa-iN8zx9TP_lmKs8c-iH3Naewt5UjJ0AQ38QZs4lkEo4zdjMIVkLs4y7EiwIE.woff2 +0 -0
  101. package/dist/client/_fonts/gRxGIWazSFZVyzU0s62U9IArK3RJLkOoUmXx0C8Npsw-kMFNQG6iwjw2nvqS3ut9jMSVn__HlJ28slvxjE4hYfc.woff2 +0 -0
  102. package/dist/client/_fonts/hIKtJJBMNYGPUppSYZpyuF6c24cKhBkhsgaCTgzYgqw-jRJyBPlfGDXClyrgfO6GK_Pfs1RmTsB-wWX6MOgpsRA.woff2 +0 -0
  103. package/dist/client/_fonts/iEvApgDRmzKzNqOYocBTrmcHZmuGAJloawKDP1S0nyE-T3oc_9We24QGwfw5naik4cM0g7VxylWVaQwKm4dy3cw.woff2 +0 -0
  104. package/dist/client/_fonts/kokcBTWRechd97ZdVUpUxrOFbsRt8whO21yA1vQ6iJ8-O7CCbVvFgg_MFLTdyFF9FMeMvIoEmxJLubqVDYTUoWY.woff2 +0 -0
  105. package/dist/client/_fonts/oFzdhjQtZFydTZ757bmiVFXgReR2bBSYm_CjQ7B1Jjs-F6oFbDhOWKYJbgrlC93wkLkPlIV7mzgvqwqEDxQMeHA.woff2 +0 -0
  106. package/dist/client/_nuxt/5ZF0DUKe.js +0 -1
  107. package/dist/client/_nuxt/8XcEHgiq.js +0 -1
  108. package/dist/client/_nuxt/B2G1Husz.js +0 -1
  109. package/dist/client/_nuxt/B6Rjxwce.js +0 -1
  110. package/dist/client/_nuxt/BTnenz-7.js +0 -1
  111. package/dist/client/_nuxt/BaarzCY9.js +0 -181
  112. package/dist/client/_nuxt/BeMtTGFX.js +0 -1
  113. package/dist/client/_nuxt/BgRd_GNf.js +0 -1
  114. package/dist/client/_nuxt/Bj_3pTUi.js +0 -1
  115. package/dist/client/_nuxt/BqgETAYZ.js +0 -1
  116. package/dist/client/_nuxt/C1-eNu7x.js +0 -1
  117. package/dist/client/_nuxt/C6MORWr4.js +0 -1
  118. package/dist/client/_nuxt/CIJ7g9su.js +0 -1
  119. package/dist/client/_nuxt/CINkxRg5.js +0 -1
  120. package/dist/client/_nuxt/COIEcBZR.js +0 -1
  121. package/dist/client/_nuxt/CVO1_9PV.js +0 -1
  122. package/dist/client/_nuxt/CZ3hLIr1.js +0 -1
  123. package/dist/client/_nuxt/Caedg1qp.js +0 -1
  124. package/dist/client/_nuxt/Cmw_hYOm.js +0 -1
  125. package/dist/client/_nuxt/Cp-IABpG.js +0 -1
  126. package/dist/client/_nuxt/CxFX6b0M.js +0 -1
  127. package/dist/client/_nuxt/D0r3Knsf.js +0 -1
  128. package/dist/client/_nuxt/D4YjxrHq.js +0 -1
  129. package/dist/client/_nuxt/DHOdika3.js +0 -1
  130. package/dist/client/_nuxt/DSdw0YSI.js +0 -1
  131. package/dist/client/_nuxt/DSxZHkX-.js +0 -1
  132. package/dist/client/_nuxt/Dn8lRF86.js +0 -1
  133. package/dist/client/_nuxt/DwNiGCgn.js +0 -1
  134. package/dist/client/_nuxt/O3qB0pnO.js +0 -1
  135. package/dist/client/_nuxt/ProsePre.D5orA6B_.css +0 -1
  136. package/dist/client/_nuxt/ZdghZ1ke.js +0 -1
  137. package/dist/client/_nuxt/aUtIlT-b.js +0 -1
  138. package/dist/client/_nuxt/builds/latest.json +0 -1
  139. package/dist/client/_nuxt/builds/meta/6319eec7-8aee-40f4-abcf-31c51d4b20a5.json +0 -1
  140. package/dist/client/_nuxt/entry.D1qdnVLM.css +0 -1
  141. package/dist/client/_nuxt/error-404.BBebgf1Y.css +0 -1
  142. package/dist/client/_nuxt/error-500.C4WF4yER.css +0 -1
  143. package/dist/client/index.html +0 -1
package/dist/module.mjs CHANGED
@@ -1,276 +1,43 @@
1
- import { useNuxt, loadNuxtModuleInstance, extendPages, tryUseNuxt, addTypeTemplate, addTemplate, defineNuxtModule, createResolver, useLogger, hasNuxtModule, getNuxtModuleVersion, hasNuxtModuleCompatibility, addServerImports, addServerPlugin, resolveModule, addServerHandler, addPrerenderRoutes } from '@nuxt/kit';
2
- import { withHttps, withBase, joinURL, withTrailingSlash, withoutLeadingSlash, withLeadingSlash, withoutTrailingSlash } from 'ufo';
3
- import { withSiteUrl, installNuxtSiteConfig } from 'nuxt-site-config/kit';
1
+ import { useNuxt, hasNuxtModule, addTypeTemplate, addTemplate, defineNuxtModule, createResolver, useLogger, getNuxtModuleVersion, hasNuxtModuleCompatibility, addServerImports, addPrerenderRoutes, addServerPlugin, resolveModule, addServerHandler } from '@nuxt/kit';
4
2
  import { defu } from 'defu';
3
+ import { withSiteUrl, installNuxtSiteConfig } from 'nuxt-site-config/kit';
4
+ import { isPathFile } from 'nuxt-site-config/urls';
5
+ import { dirname, extname } from 'pathe';
5
6
  import { readPackageJSON } from 'pkg-types';
6
- import { extname, dirname } from 'pathe';
7
- import { statSync, readFileSync, existsSync } from 'node:fs';
8
- import { createPathFilter, splitForLocales, mergeOnKey } from '../dist/runtime/utils-pure.js';
9
- import { provider, env } from 'std-env';
7
+ import { withBase, withHttps, withTrailingSlash, withoutLeadingSlash, joinURL, withLeadingSlash, withoutTrailingSlash } from 'ufo';
8
+ import { setupDevToolsUI as setupDevToolsUI$1 } from 'nuxtseo-shared/devtools';
9
+ import { readFileSync, statSync } from 'node:fs';
10
10
  import { mkdir, writeFile } from 'node:fs/promises';
11
11
  import { join } from 'node:path';
12
- import chalk from 'chalk';
13
- import { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.Bj0OAEtK.mjs';
14
- import { addCustomTab } from '@nuxt/devtools-kit';
12
+ import { colors } from 'consola/utils';
13
+ import { splitForLocales, createPathFilter } from '../dist/runtime/utils-pure.js';
14
+ import { isNuxtGenerate, resolveNitroPreset, getNuxtModuleOptions, resolveNuxtContentVersion, createPagesPromise, createNitroPromise } from 'nuxtseo-shared/kit';
15
+ import { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.B99ug6A9.mjs';
15
16
  import { normaliseDate } from '../dist/runtime/server/sitemap/urlset/normalise.js';
16
- import { isPathFile } from 'nuxt-site-config/urls';
17
+ import { splitPathForI18nLocales as splitPathForI18nLocales$1, normalizeLocales, generatePathForI18nPages } from 'nuxtseo-shared/i18n';
17
18
  import 'ultrahtml';
18
19
 
19
- async function resolveUrls(urls, ctx) {
20
- try {
21
- if (typeof urls === "function")
22
- urls = urls();
23
- urls = await urls;
24
- } catch (e) {
25
- ctx.logger.error(`Failed to resolve ${typeof urls} urls.`);
26
- ctx.logger.error(e);
27
- return [];
28
- }
29
- try {
30
- urls = JSON.parse(JSON.stringify(urls));
31
- } catch (e) {
32
- ctx.logger.error(`Failed to serialize ${typeof urls} \`${ctx.path}\`, please make sure that the urls resolve as a valid array without circular dependencies.`);
33
- ctx.logger.error(e);
34
- return [];
35
- }
36
- return urls;
37
- }
38
- function deepForEachPage(pages, callback, opts, fullpath = null, depth = 0) {
39
- pages.forEach((page) => {
40
- let currentPath;
41
- if (page.path.startsWith("/")) {
42
- currentPath = page.path;
43
- } else {
44
- currentPath = page.path === "" ? fullpath : `${fullpath.replace(/\/$/, "")}/${page.path}`;
45
- }
46
- let didCallback = false;
47
- if (opts.isI18nMicro) {
48
- const localePattern = /\/:locale\(([^)]+)\)/;
49
- const match = localePattern.exec(currentPath || "");
50
- if (match && match[1]) {
51
- const locales = match[1].split("|");
52
- locales.forEach((locale) => {
53
- const subPage = { ...page };
54
- const localizedPath = (currentPath || "").replace(localePattern, `/${locale}`);
55
- subPage.name += opts.routesNameSeparator + locale;
56
- subPage.path = localizedPath;
57
- callback(subPage, localizedPath || "", depth);
58
- didCallback = true;
59
- });
60
- }
61
- }
62
- if (!didCallback) {
63
- callback(page, currentPath || "", depth);
64
- }
65
- if (page.children) {
66
- deepForEachPage(page.children, callback, opts, currentPath, depth + 1);
67
- }
68
- });
69
- }
70
- function convertNuxtPagesToSitemapEntries(pages, config) {
71
- const pathFilter = createPathFilter(config.filter);
72
- const routesNameSeparator = config.routesNameSeparator || "___";
73
- let flattenedPages = [];
74
- deepForEachPage(
75
- pages,
76
- (page, loc, depth) => {
77
- flattenedPages.push({ page, loc, depth });
78
- },
79
- {
80
- ...config,
81
- routesNameSeparator: config.routesNameSeparator || "___"
82
- }
20
+ function setupDevToolsUI(_options, resolve, nuxt = useNuxt()) {
21
+ setupDevToolsUI$1(
22
+ { route: "/__nuxt-sitemap", name: "sitemap", title: "Sitemap", icon: "carbon:load-balancer-application" },
23
+ resolve,
24
+ nuxt
83
25
  );
84
- flattenedPages = flattenedPages.filter((page) => !page.loc.includes(":")).filter((page, idx, arr) => {
85
- return !arr.find((p) => {
86
- return p.loc === page.loc && p.depth > page.depth;
87
- });
88
- }).map((p) => {
89
- delete p.depth;
90
- return p;
91
- });
92
- if (config.strategy === "prefix_and_default") {
93
- flattenedPages = flattenedPages.filter((p) => {
94
- if (p.page?.name) {
95
- const [, locale] = p.page.name.split(routesNameSeparator);
96
- return locale !== config.defaultLocale || p.page.name.endsWith("__default");
97
- }
98
- return true;
99
- });
100
- }
101
- const pagesWithMeta = flattenedPages.map((p) => {
102
- if (config.autoLastmod && p.page.file) {
103
- const stats = statSync(p.page.file, { throwIfNoEntry: false });
104
- if (stats?.mtime)
105
- p.lastmod = stats.mtime;
106
- }
107
- if (p.page?.meta?.sitemap) {
108
- p = defu(p.page.meta.sitemap, p);
109
- }
110
- return p;
111
- });
112
- const localeGroups = {};
113
- pagesWithMeta.reduce((acc, e) => {
114
- if (e.page.name?.includes(routesNameSeparator)) {
115
- const [name, locale] = e.page.name.split(routesNameSeparator);
116
- if (!name)
117
- return acc;
118
- if (!acc[name])
119
- acc[name] = [];
120
- const { _sitemap } = config.normalisedLocales.find((l) => l.code === locale) || { _sitemap: locale };
121
- acc[name].push({ ...e, _sitemap: config.isI18nMapped ? _sitemap : void 0, locale });
122
- } else {
123
- acc.default = acc.default || [];
124
- acc.default.push(e);
125
- }
126
- return acc;
127
- }, localeGroups);
128
- return Object.entries(localeGroups).map(([locale, entries]) => {
129
- if (locale === "default") {
130
- return entries.map((e) => {
131
- const [name] = (e.page?.name || "").split(routesNameSeparator);
132
- if (!name)
133
- return false;
134
- if (localeGroups[name]?.some((a) => a.locale === config.defaultLocale))
135
- return false;
136
- const defaultLocale = config.normalisedLocales.find((l) => l.code === config.defaultLocale);
137
- if (defaultLocale && config.isI18nMapped)
138
- e._sitemap = defaultLocale._sitemap;
139
- delete e.page;
140
- delete e.locale;
141
- return { ...e };
142
- }).filter(Boolean);
143
- }
144
- return entries.map((entry) => {
145
- const alternatives = entries.map((entry2) => {
146
- const locale2 = config.normalisedLocales.find((l) => l.code === entry2.locale);
147
- if (!pathFilter(entry2.loc))
148
- return false;
149
- const href = locale2?.domain ? withHttps(withBase(entry2.loc, locale2?.domain)) : entry2.loc;
150
- return {
151
- hreflang: locale2?._hreflang,
152
- href
153
- };
154
- }).filter(Boolean);
155
- const xDefault = entries.find((a) => a.locale === config.defaultLocale);
156
- if (xDefault && alternatives.length && pathFilter(xDefault.loc)) {
157
- const locale2 = config.normalisedLocales.find((l) => l.code === xDefault.locale);
158
- const href = locale2?.domain ? withHttps(withBase(xDefault.loc, locale2?.domain)) : xDefault.loc;
159
- alternatives.push({
160
- hreflang: "x-default",
161
- href
162
- });
163
- }
164
- const e = { ...entry };
165
- if (config.isI18nMapped) {
166
- const { _sitemap } = config.normalisedLocales.find((l) => l.code === entry.locale) || { _sitemap: locale };
167
- e._sitemap = _sitemap;
168
- }
169
- delete e.page;
170
- delete e.locale;
171
- return {
172
- ...e,
173
- alternatives
174
- };
175
- });
176
- }).filter(Boolean).flat();
177
- }
178
- function generateExtraRoutesFromNuxtConfig(nuxt = useNuxt()) {
179
- const filterForValidPage = (p) => typeof p === "string" && !!p && !extname(p) && !p.startsWith("/api/") && !p.startsWith("/_");
180
- const routeRules = Object.entries(nuxt.options.routeRules || {}).filter(([k, v]) => {
181
- if (k.includes("*") || k.includes(".") || k.includes(":"))
182
- return false;
183
- if ("robots" in v && typeof v.robots === "boolean" && !v.robots)
184
- return false;
185
- return !v.redirect;
186
- }).map(([k]) => k).filter(filterForValidPage);
187
- const prerenderUrls = (nuxt.options.nitro.prerender?.routes || []).filter(filterForValidPage);
188
- return { routeRules, prerenderUrls };
189
- }
190
-
191
- async function getNuxtModuleOptions(module, nuxt = useNuxt()) {
192
- const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
193
- const { nuxtModule } = await loadNuxtModuleInstance(module, nuxt);
194
- let moduleEntry;
195
- for (const m of nuxt.options.modules) {
196
- if (Array.isArray(m) && m.length >= 2) {
197
- const _module = m[0];
198
- const _moduleEntryName = typeof _module === "string" ? _module : (await _module.getMeta?.())?.name || "";
199
- if (_moduleEntryName === moduleMeta.name)
200
- moduleEntry = m;
201
- }
202
- }
203
- let inlineOptions = {};
204
- if (moduleEntry)
205
- inlineOptions = moduleEntry[1];
206
- if (nuxtModule.getOptions)
207
- return nuxtModule.getOptions(inlineOptions, nuxt);
208
- return inlineOptions;
209
- }
210
- function createPagesPromise(nuxt = useNuxt()) {
211
- return new Promise((resolve) => {
212
- nuxt.hooks.hook("modules:done", () => {
213
- if (typeof nuxt.options.pages === "boolean" && nuxt.options.pages === false || typeof nuxt.options.pages === "object" && !nuxt.options.pages.enabled) {
214
- return resolve([]);
215
- }
216
- extendPages(resolve);
217
- });
218
- });
219
- }
220
- function createNitroPromise(nuxt = useNuxt()) {
221
- return new Promise((resolve) => {
222
- nuxt.hooks.hook("nitro:init", (nitro) => {
223
- resolve(nitro);
224
- });
225
- });
226
- }
227
- const autodetectableProviders = {
228
- azure_static: "azure",
229
- cloudflare_pages: "cloudflare-pages",
230
- netlify: "netlify",
231
- stormkit: "stormkit",
232
- vercel: "vercel",
233
- cleavr: "cleavr",
234
- stackblitz: "stackblitz"
235
- };
236
- const autodetectableStaticProviders = {
237
- netlify: "netlify-static",
238
- vercel: "vercel-static"
239
- };
240
- function detectTarget(options = {}) {
241
- return options?.static ? autodetectableStaticProviders[provider] : autodetectableProviders[provider];
242
- }
243
- function resolveNitroPreset(nitroConfig) {
244
- nitroConfig = nitroConfig || tryUseNuxt()?.options?.nitro;
245
- if (provider === "stackblitz")
246
- return "stackblitz";
247
- let preset;
248
- if (nitroConfig && nitroConfig?.preset)
249
- preset = nitroConfig.preset;
250
- if (!preset)
251
- preset = env.NITRO_PRESET || env.SERVER_PRESET || detectTarget() || "node-server";
252
- return preset.replace("_", "-");
253
26
  }
254
27
 
255
28
  function formatPrerenderRoute(route) {
256
29
  let str = ` \u251C\u2500 ${route.route} (${route.generateTimeMS}ms)`;
257
30
  if (route.error) {
258
- const errorColor = chalk[route.error.statusCode === 404 ? "yellow" : "red"];
31
+ const errorColor = colors[route.error.statusCode === 404 ? "yellow" : "red"];
259
32
  const errorLead = "\u2514\u2500\u2500";
260
33
  str += `
261
- \u2502 ${errorLead} ${errorColor(route.error)}`;
34
+ \u2502 ${errorLead} ${errorColor(route.error.message)}`;
262
35
  }
263
- return chalk.gray(str);
36
+ return colors.gray(str);
264
37
  }
265
38
  function includesSitemapRoot(sitemapName, routes) {
266
39
  return routes.includes(`/__sitemap__/`) || routes.includes(`/sitemap.xml`) || routes.includes(`/${sitemapName}`) || routes.includes("/sitemap_index.xml");
267
40
  }
268
- function isNuxtGenerate(nuxt = useNuxt()) {
269
- return nuxt.options.nitro.static || nuxt.options._generate || [
270
- "static",
271
- "github-pages"
272
- ].includes(resolveNitroPreset());
273
- }
274
41
  const NuxtRedirectHtmlRegex = /<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=([^"]+)"><\/head><\/html>/;
275
42
  function setupPrerenderHandler(_options, nuxt = useNuxt()) {
276
43
  const { runtimeConfig: options, logger, generateGlobalSources, generateChildSources } = _options;
@@ -285,7 +52,7 @@ function setupPrerenderHandler(_options, nuxt = useNuxt()) {
285
52
  const shouldHookIntoPrerender = prerenderSitemap || nuxt.options.nitro.prerender.routes.length && nuxt.options.nitro.prerender.crawlLinks;
286
53
  if (isNuxtGenerate() && options.debug) {
287
54
  nuxt.options.nitro.prerender.routes.push("/__sitemap__/debug.json");
288
- logger.info("Adding debug route for sitemap generation:", chalk.cyan("/__sitemap__/debug.json"));
55
+ logger.info("Adding debug route for sitemap generation:", colors.cyan("/__sitemap__/debug.json"));
289
56
  }
290
57
  if (!shouldHookIntoPrerender) {
291
58
  return;
@@ -313,7 +80,7 @@ export async function readSourcesFromFilesystem(filename) {
313
80
  const html = route.contents;
314
81
  if (!route.fileName?.endsWith(".html") || !html || ["/200.html", "/404.html"].includes(route.route))
315
82
  return;
316
- if (html.match(NuxtRedirectHtmlRegex)) {
83
+ if (NuxtRedirectHtmlRegex.test(html)) {
317
84
  return;
318
85
  }
319
86
  const extractedMeta = parseHtmlExtractSitemapMeta(html, {
@@ -367,7 +134,8 @@ async function prerenderSitemapsFromEntry(nitro, entry) {
367
134
  const processed = /* @__PURE__ */ new Set();
368
135
  while (queue.length) {
369
136
  const route = queue.shift();
370
- if (processed.has(route)) continue;
137
+ if (processed.has(route))
138
+ continue;
371
139
  processed.add(route);
372
140
  const { filePath, prerenderUrls } = await prerenderRoute(nitro, route);
373
141
  sitemaps.push({
@@ -408,121 +176,13 @@ async function prerenderRoute(nitro, route) {
408
176
  return { filePath, prerenderUrls };
409
177
  }
410
178
 
411
- const DEVTOOLS_UI_ROUTE = "/__sitemap__/devtools";
412
- const DEVTOOLS_UI_LOCAL_PORT = 3030;
413
- function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
414
- const clientPath = resolve("./client");
415
- const isProductionBuild = existsSync(clientPath);
416
- if (isProductionBuild) {
417
- nuxt.hook("vite:serverCreated", async (server) => {
418
- const sirv = await import('sirv').then((r) => r.default || r);
419
- server.middlewares.use(
420
- DEVTOOLS_UI_ROUTE,
421
- sirv(clientPath, { dev: true, single: true })
422
- );
423
- });
424
- } else {
425
- nuxt.hook("vite:extendConfig", (config) => {
426
- Object.assign(config, {
427
- server: {
428
- ...config.server,
429
- proxy: {
430
- ...config.server?.proxy,
431
- [DEVTOOLS_UI_ROUTE]: {
432
- target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
433
- changeOrigin: true,
434
- followRedirects: true,
435
- rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
436
- }
437
- }
438
- }
439
- });
440
- });
441
- }
442
- addCustomTab({
443
- // unique identifier
444
- name: "sitemap",
445
- // title to display in the tab
446
- title: "Sitemap",
447
- // any icon from Iconify, or a URL to an image
448
- icon: "carbon:load-balancer-application",
449
- // iframe view
450
- view: {
451
- type: "iframe",
452
- src: DEVTOOLS_UI_ROUTE
453
- }
454
- });
455
- }
456
-
457
- function splitPathForI18nLocales(path, autoI18n) {
458
- const locales = autoI18n.strategy === "prefix_except_default" ? autoI18n.locales.filter((l) => l.code !== autoI18n.defaultLocale) : autoI18n.locales;
459
- if (typeof path !== "string" || path.startsWith("/_"))
460
- return path;
461
- const match = splitForLocales(path, locales.map((l) => l.code));
462
- const locale = match[0];
463
- if (locale)
464
- return path;
465
- return [
466
- path,
467
- ...locales.map((l) => `/${l.code}${path}`)
468
- ];
469
- }
470
- function generatePathForI18nPages(ctx) {
471
- const { localeCode, pageLocales, nuxtI18nConfig, forcedStrategy, normalisedLocales } = ctx;
472
- const locale = normalisedLocales.find((l) => l.code === localeCode);
473
- let path = pageLocales;
474
- switch (forcedStrategy ?? nuxtI18nConfig.strategy) {
475
- case "prefix_except_default":
476
- case "prefix_and_default":
477
- path = localeCode === nuxtI18nConfig.defaultLocale ? pageLocales : joinURL(localeCode, pageLocales);
478
- break;
479
- case "prefix":
480
- path = joinURL(localeCode, pageLocales);
481
- break;
482
- }
483
- return locale?.domain ? withHttps(withBase(path, locale.domain)) : path;
484
- }
485
- function normalizeLocales(nuxtI18nConfig) {
486
- const rawLocales = nuxtI18nConfig.locales || [];
487
- let onlyLocales = nuxtI18nConfig?.bundle?.onlyLocales || [];
488
- onlyLocales = typeof onlyLocales === "string" ? [onlyLocales] : onlyLocales;
489
- let locales = mergeOnKey(rawLocales.map((locale) => typeof locale === "string" ? { code: locale } : locale), "code");
490
- if (onlyLocales.length) {
491
- locales = locales.filter((locale) => onlyLocales.includes(locale.code));
492
- }
493
- return locales.map((locale) => {
494
- if (typeof locale.iso === "string" && !locale.language) {
495
- locale.language = locale.iso;
496
- }
497
- const _hreflang = locale.language || locale.code;
498
- const _sitemap = locale.language || locale.code;
499
- return { ...locale, _hreflang, _sitemap };
500
- });
501
- }
502
-
503
- function isValidFilter(filter) {
504
- if (typeof filter === "string")
505
- return true;
506
- if (filter instanceof RegExp)
507
- return true;
508
- if (typeof filter === "object" && typeof filter.regex === "string")
509
- return true;
510
- return false;
511
- }
512
- function normalizeFilters(filters) {
513
- return (filters || []).map((filter) => {
514
- if (!isValidFilter(filter)) {
515
- console.warn(`[@nuxtjs/sitemap] You have provided an invalid filter: ${filter}, ignoring.`);
516
- return false;
517
- }
518
- return filter instanceof RegExp ? { regex: filter.toString() } : filter;
519
- }).filter(Boolean);
520
- }
521
-
522
179
  function registerTypeTemplates() {
180
+ const hasRobotsModule = hasNuxtModule("@nuxtjs/robots") || hasNuxtModule("nuxt-simple-robots");
523
181
  addTypeTemplate({
524
182
  filename: "types/nuxt-sitemap-augments.d.ts",
525
- getContents: () => `// Generated by @nuxtjs/sitemap
183
+ getContents: () => {
184
+ const robotsType = hasRobotsModule ? "" : " robots?: boolean\n";
185
+ return `// Generated by @nuxtjs/sitemap
526
186
  /// <reference path="./nuxt-sitemap-virtual.d.ts" />
527
187
  import type { SitemapUrl, SitemapItemDefaults, SitemapIndexRenderCtx, SitemapInputCtx, SitemapRenderCtx, SitemapOutputHookCtx, SitemapSourcesHookCtx } from '@nuxtjs/sitemap'
528
188
 
@@ -531,12 +191,10 @@ declare module 'nitropack' {
531
191
  _sitemap?: SitemapUrl
532
192
  }
533
193
  interface NitroRouteRules {
534
- index?: boolean
535
- sitemap?: SitemapItemDefaults | false
194
+ ${robotsType} sitemap?: SitemapItemDefaults | false
536
195
  }
537
196
  interface NitroRouteConfig {
538
- index?: boolean
539
- sitemap?: SitemapItemDefaults | false
197
+ ${robotsType} sitemap?: SitemapItemDefaults | false
540
198
  }
541
199
  interface NitroRuntimeHooks {
542
200
  'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
@@ -552,12 +210,10 @@ declare module 'nitropack/types' {
552
210
  _sitemap?: SitemapUrl
553
211
  }
554
212
  interface NitroRouteRules {
555
- index?: boolean
556
- sitemap?: SitemapItemDefaults | false
213
+ ${robotsType} sitemap?: SitemapItemDefaults | false
557
214
  }
558
215
  interface NitroRouteConfig {
559
- index?: boolean
560
- sitemap?: SitemapItemDefaults | false
216
+ ${robotsType} sitemap?: SitemapItemDefaults | false
561
217
  }
562
218
  interface NitroRuntimeHooks {
563
219
  'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
@@ -587,7 +243,8 @@ declare module 'nuxt/app' {
587
243
  }
588
244
 
589
245
  export {}
590
- `
246
+ `;
247
+ }
591
248
  });
592
249
  addTemplate({
593
250
  filename: "types/nuxt-sitemap-virtual.d.ts",
@@ -618,6 +275,203 @@ declare module '#sitemap/content-on-url' {
618
275
  });
619
276
  }
620
277
 
278
+ function isValidFilter(filter) {
279
+ if (typeof filter === "string")
280
+ return true;
281
+ if (filter instanceof RegExp)
282
+ return true;
283
+ if (typeof filter === "object" && typeof filter.regex === "string")
284
+ return true;
285
+ return false;
286
+ }
287
+ function normalizeFilters(filters) {
288
+ return (filters || []).map((filter) => {
289
+ if (!isValidFilter(filter)) {
290
+ console.warn(`[@nuxtjs/sitemap] You have provided an invalid filter: ${filter}, ignoring.`);
291
+ return false;
292
+ }
293
+ return filter instanceof RegExp ? { regex: filter.toString() } : filter;
294
+ }).filter(Boolean);
295
+ }
296
+
297
+ function splitPathForI18nLocales(path, autoI18n) {
298
+ if (typeof path !== "string")
299
+ return path;
300
+ return splitPathForI18nLocales$1(path, autoI18n);
301
+ }
302
+
303
+ async function resolveUrls(urls, ctx) {
304
+ try {
305
+ if (typeof urls === "function")
306
+ urls = urls();
307
+ urls = await urls;
308
+ } catch (e) {
309
+ ctx.logger.error(`Failed to resolve ${typeof urls} urls.`);
310
+ ctx.logger.error(e);
311
+ return [];
312
+ }
313
+ try {
314
+ urls = JSON.parse(JSON.stringify(urls));
315
+ } catch (e) {
316
+ ctx.logger.error(`Failed to serialize ${typeof urls} \`${ctx.path}\`, please make sure that the urls resolve as a valid array without circular dependencies.`);
317
+ ctx.logger.error(e);
318
+ return [];
319
+ }
320
+ return urls;
321
+ }
322
+ function deepForEachPage(pages, callback, opts, fullpath = null, depth = 0) {
323
+ pages.forEach((page) => {
324
+ let currentPath;
325
+ if (page.path.startsWith("/")) {
326
+ currentPath = page.path;
327
+ } else {
328
+ currentPath = page.path === "" ? fullpath : `${fullpath.replace(/\/$/, "")}/${page.path}`;
329
+ }
330
+ let didCallback = false;
331
+ if (opts.isI18nMicro) {
332
+ const localePattern = /\/:locale\(([^)]+)\)/;
333
+ const match = localePattern.exec(currentPath || "");
334
+ if (match && match[1]) {
335
+ const locales = match[1].split("|");
336
+ locales.forEach((locale) => {
337
+ const subPage = { ...page };
338
+ const localizedPath = (currentPath || "").replace(localePattern, `/${locale}`);
339
+ subPage.name += opts.routesNameSeparator + locale;
340
+ subPage.path = localizedPath;
341
+ callback(subPage, localizedPath || "", depth);
342
+ didCallback = true;
343
+ });
344
+ }
345
+ }
346
+ if (!didCallback) {
347
+ callback(page, currentPath || "", depth);
348
+ }
349
+ if (page.children) {
350
+ deepForEachPage(page.children, callback, opts, currentPath, depth + 1);
351
+ }
352
+ });
353
+ }
354
+ function convertNuxtPagesToSitemapEntries(pages, config) {
355
+ const pathFilter = createPathFilter(config.filter);
356
+ const routesNameSeparator = config.routesNameSeparator || "___";
357
+ let flattenedPages = [];
358
+ deepForEachPage(
359
+ pages,
360
+ (page, loc, depth) => {
361
+ flattenedPages.push({ page, loc, depth });
362
+ },
363
+ {
364
+ ...config,
365
+ routesNameSeparator: config.routesNameSeparator || "___"
366
+ }
367
+ );
368
+ flattenedPages = flattenedPages.filter((page) => !page.loc.includes(":")).filter((page, idx, arr) => {
369
+ return !arr.some((p) => {
370
+ return p.loc === page.loc && p.depth > page.depth;
371
+ });
372
+ }).map((p) => {
373
+ delete p.depth;
374
+ return p;
375
+ });
376
+ if (config.strategy === "prefix_and_default") {
377
+ flattenedPages = flattenedPages.filter((p) => {
378
+ if (p.page?.name) {
379
+ const [, locale] = p.page.name.split(routesNameSeparator);
380
+ return locale !== config.defaultLocale || p.page.name.endsWith("__default");
381
+ }
382
+ return true;
383
+ });
384
+ }
385
+ const pagesWithMeta = flattenedPages.map((p) => {
386
+ if (config.autoLastmod && p.page.file) {
387
+ const stats = statSync(p.page.file, { throwIfNoEntry: false });
388
+ if (stats?.mtime)
389
+ p.lastmod = stats.mtime;
390
+ }
391
+ if (p.page?.meta?.sitemap) {
392
+ p = defu(p.page.meta.sitemap, p);
393
+ }
394
+ return p;
395
+ });
396
+ const localeGroups = {};
397
+ pagesWithMeta.reduce((acc, e) => {
398
+ if (e.page.name?.includes(routesNameSeparator)) {
399
+ const [name, locale] = e.page.name.split(routesNameSeparator);
400
+ if (!name)
401
+ return acc;
402
+ if (!acc[name])
403
+ acc[name] = [];
404
+ const { _sitemap } = config.normalisedLocales.find((l) => l.code === locale) || { _sitemap: locale };
405
+ acc[name].push({ ...e, _sitemap: config.isI18nMapped ? _sitemap : void 0, locale });
406
+ } else {
407
+ acc.default = acc.default || [];
408
+ acc.default.push(e);
409
+ }
410
+ return acc;
411
+ }, localeGroups);
412
+ return Object.entries(localeGroups).map(([locale, entries]) => {
413
+ if (locale === "default") {
414
+ return entries.map((e) => {
415
+ const [name] = (e.page?.name || "").split(routesNameSeparator);
416
+ if (!name)
417
+ return false;
418
+ if (localeGroups[name]?.some((a) => a.locale === config.defaultLocale))
419
+ return false;
420
+ const defaultLocale = config.normalisedLocales.find((l) => l.code === config.defaultLocale);
421
+ if (defaultLocale && config.isI18nMapped)
422
+ e._sitemap = defaultLocale._sitemap;
423
+ delete e.page;
424
+ delete e.locale;
425
+ return { ...e };
426
+ }).filter(Boolean);
427
+ }
428
+ return entries.map((entry) => {
429
+ const alternatives = entries.map((entry2) => {
430
+ const locale2 = config.normalisedLocales.find((l) => l.code === entry2.locale);
431
+ if (!pathFilter(entry2.loc))
432
+ return false;
433
+ const href = locale2?.domain ? withHttps(withBase(entry2.loc, locale2?.domain)) : entry2.loc;
434
+ return {
435
+ hreflang: locale2?._hreflang,
436
+ href
437
+ };
438
+ }).filter(Boolean);
439
+ const xDefault = entries.find((a) => a.locale === config.defaultLocale);
440
+ if (xDefault && alternatives.length && pathFilter(xDefault.loc)) {
441
+ const locale2 = config.normalisedLocales.find((l) => l.code === xDefault.locale);
442
+ const href = locale2?.domain ? withHttps(withBase(xDefault.loc, locale2?.domain)) : xDefault.loc;
443
+ alternatives.push({
444
+ hreflang: "x-default",
445
+ href
446
+ });
447
+ }
448
+ const e = { ...entry };
449
+ if (config.isI18nMapped) {
450
+ const { _sitemap } = config.normalisedLocales.find((l) => l.code === entry.locale) || { _sitemap: locale };
451
+ e._sitemap = _sitemap;
452
+ }
453
+ delete e.page;
454
+ delete e.locale;
455
+ return {
456
+ ...e,
457
+ alternatives
458
+ };
459
+ });
460
+ }).filter(Boolean).flat();
461
+ }
462
+ function generateExtraRoutesFromNuxtConfig(nuxt = useNuxt()) {
463
+ const filterForValidPage = (p) => typeof p === "string" && !!p && !extname(p) && !p.startsWith("/api/") && !p.startsWith("/_");
464
+ const routeRules = Object.entries(nuxt.options.routeRules || {}).filter(([k, v]) => {
465
+ if (k.includes("*") || k.includes(".") || k.includes(":"))
466
+ return false;
467
+ if ("robots" in v && typeof v.robots === "boolean" && !v.robots)
468
+ return false;
469
+ return !v.redirect;
470
+ }).map(([k]) => k).filter(filterForValidPage);
471
+ const prerenderUrls = (nuxt.options.nitro.prerender?.routes || []).filter(filterForValidPage);
472
+ return { routeRules, prerenderUrls };
473
+ }
474
+
621
475
  const module$1 = defineNuxtModule({
622
476
  meta: {
623
477
  name: "@nuxtjs/sitemap",
@@ -636,7 +490,7 @@ const module$1 = defineNuxtModule({
636
490
  optional: true
637
491
  },
638
492
  "nuxt-site-config": {
639
- version: ">=3"
493
+ version: ">=3.2"
640
494
  },
641
495
  "@nuxt/content": {
642
496
  version: ">=2",
@@ -749,9 +603,6 @@ const module$1 = defineNuxtModule({
749
603
  if (i18nVersion && i18nModule === "@nuxtjs/i18n" && !await hasNuxtModuleCompatibility(i18nModule, ">=8"))
750
604
  logger.warn(`You are using ${i18nModule} v${i18nVersion}. For the best compatibility, please upgrade to ${i18nModule} v8.0.0 or higher.`);
751
605
  nuxtI18nConfig = await getNuxtModuleOptions(i18nModule) || {};
752
- if (typeof nuxtI18nConfig.includeDefaultLocaleRoute !== "undefined") {
753
- nuxtI18nConfig.strategy = nuxtI18nConfig.includeDefaultLocaleRoute ? "prefix" : "prefix_except_default";
754
- }
755
606
  normalisedLocales = normalizeLocales(nuxtI18nConfig);
756
607
  usingI18nPages = !!Object.keys(nuxtI18nConfig.pages || {}).length;
757
608
  if (usingI18nPages && !hasDisabledAutoI18n) {
@@ -810,16 +661,48 @@ const module$1 = defineNuxtModule({
810
661
  pages: nuxtI18nConfig.pages
811
662
  };
812
663
  }
813
- let canI18nMap = config.sitemaps !== false && nuxtI18nConfig.strategy !== "no_prefix";
664
+ let canI18nMap = !hasDisabledAutoI18n && config.sitemaps !== false && nuxtI18nConfig.strategy !== "no_prefix";
814
665
  if (typeof config.sitemaps === "object") {
815
- const isSitemapIndexOnly = typeof config.sitemaps.index !== "undefined" && Object.keys(config.sitemaps).length === 1;
816
- if (!isSitemapIndexOnly)
666
+ const sitemapEntries = Object.entries(config.sitemaps).filter(([k]) => k !== "index");
667
+ const isSitemapIndexOnly = sitemapEntries.length === 0;
668
+ const hasIncludeAppSources = sitemapEntries.some(([_, v]) => v && typeof v === "object" && v.includeAppSources);
669
+ if (!isSitemapIndexOnly && !hasIncludeAppSources)
817
670
  canI18nMap = false;
818
671
  }
819
672
  if (canI18nMap && resolvedAutoI18n) {
820
- config.sitemaps = { index: [...config.sitemaps?.index || [], ...config.appendSitemaps || []] };
821
- for (const locale of resolvedAutoI18n.locales)
822
- config.sitemaps[locale._sitemap] = { includeAppSources: true };
673
+ const existingSitemaps = typeof config.sitemaps === "object" ? config.sitemaps : {};
674
+ const i18nSitemaps = [];
675
+ const nonI18nSitemaps = {};
676
+ for (const [name2, cfg] of Object.entries(existingSitemaps)) {
677
+ if (name2 === "index")
678
+ continue;
679
+ if (cfg && typeof cfg === "object" && cfg.includeAppSources) {
680
+ i18nSitemaps.push({ name: name2, cfg });
681
+ } else {
682
+ nonI18nSitemaps[name2] = cfg;
683
+ }
684
+ }
685
+ const newSitemaps = {
686
+ index: [...existingSitemaps.index || [], ...config.appendSitemaps || []]
687
+ };
688
+ const hasCustomI18nSitemaps = i18nSitemaps.length > 0;
689
+ if (hasCustomI18nSitemaps) {
690
+ for (const { name: name2, cfg } of i18nSitemaps) {
691
+ for (const locale of resolvedAutoI18n.locales) {
692
+ newSitemaps[`${locale._sitemap}-${name2}`] = {
693
+ includeAppSources: true,
694
+ ...cfg.exclude?.length && { exclude: cfg.exclude },
695
+ ...cfg.include?.length && { include: cfg.include }
696
+ };
697
+ }
698
+ }
699
+ } else {
700
+ for (const locale of resolvedAutoI18n.locales) {
701
+ newSitemaps[locale._sitemap] = { includeAppSources: true };
702
+ }
703
+ }
704
+ Object.assign(newSitemaps, nonI18nSitemaps);
705
+ config.sitemaps = newSitemaps;
823
706
  isI18nMapped = true;
824
707
  usingMultiSitemaps = true;
825
708
  }
@@ -852,9 +735,7 @@ const module$1 = defineNuxtModule({
852
735
  let prerenderSitemap = isNuxtGenerate() || includesSitemapRoot(config.sitemapName, prerenderedRoutes);
853
736
  if (config.zeroRuntime && !prerenderSitemap) {
854
737
  prerenderSitemap = true;
855
- nuxt.options.nitro.prerender = nuxt.options.nitro.prerender || {};
856
- nuxt.options.nitro.prerender.routes = nuxt.options.nitro.prerender.routes || [];
857
- nuxt.options.nitro.prerender.routes.push("/sitemap.xml");
738
+ addPrerenderRoutes("/sitemap.xml");
858
739
  logger.info("`zeroRuntime` enabled - sitemap routes will be prerendered.");
859
740
  }
860
741
  const routesPath = config.zeroRuntime ? "./runtime/server/routes/__zero-runtime" : "./runtime/server/routes";
@@ -875,7 +756,7 @@ const module$1 = defineNuxtModule({
875
756
  };
876
757
  }
877
758
  if (usingMultiSitemaps) {
878
- nuxt.options.nitro.routeRules["/sitemap.xml"] = { redirect: "/sitemap_index.xml" };
759
+ nuxt.options.nitro.routeRules["/sitemap.xml"] = { redirect: withBase("/sitemap_index.xml", nuxt.options.app.baseURL) };
879
760
  nuxt.options.nitro.routeRules["/sitemap_index.xml"] = routeRules;
880
761
  if (typeof config.sitemaps === "object") {
881
762
  for (const k in config.sitemaps) {
@@ -902,10 +783,10 @@ const module$1 = defineNuxtModule({
902
783
  addServerPlugin(resolve("./runtime/server/plugins/compression"));
903
784
  }
904
785
  const isNuxtContentDocumentDriven = !!nuxt.options.content?.documentDriven || config.strictNuxtContentPaths;
905
- const usingNuxtContent = hasNuxtModule("@nuxt/content");
906
- const isNuxtContentV3 = usingNuxtContent && await hasNuxtModuleCompatibility("@nuxt/content", "^3");
786
+ const contentVersion = await resolveNuxtContentVersion();
787
+ const isNuxtContentV3 = contentVersion && contentVersion.version === 3;
907
788
  const nuxtV3Collections = /* @__PURE__ */ new Set();
908
- const isNuxtContentV2 = usingNuxtContent && await hasNuxtModuleCompatibility("@nuxt/content", "^2");
789
+ const isNuxtContentV2 = contentVersion && contentVersion.version === 2;
909
790
  if (isNuxtContentV3) {
910
791
  if (nuxt.options._installedModules.some((m) => m.meta.name === "Content")) {
911
792
  logger.warn("You have loaded `@nuxt/content` before `@nuxtjs/sitemap`, this may cause issues with the integration. Please ensure `@nuxtjs/sitemap` is loaded first.");
@@ -917,41 +798,45 @@ const module$1 = defineNuxtModule({
917
798
  nuxt.options.alias["@nuxt/content/nitro"] = resolve("./runtime/server/content-compat");
918
799
  }
919
800
  nuxt.hooks.hook("content:file:afterParse", (ctx) => {
920
- const content = ctx.content;
921
- nuxtV3Collections.add(ctx.collection.name);
922
- if (String(ctx.content.path).includes("/.")) {
923
- ctx.content.sitemap = null;
924
- return;
925
- }
926
- if (!("sitemap" in ctx.collection.fields)) {
927
- ctx.content.sitemap = null;
928
- return;
929
- }
930
- if (typeof content.sitemap !== "undefined" && !content.sitemap) {
931
- ctx.content.sitemap = null;
932
- return;
933
- }
934
- if (ctx.content.robots === false) {
935
- ctx.content.sitemap = null;
936
- return;
937
- }
938
- const images = [];
939
- if (config.discoverImages) {
940
- images.push(
941
- ...content.body?.value?.filter(
942
- (c) => ["image", "img", "nuxtimg", "nuxt-img"].includes(c[0])
943
- ).filter((c) => c[1]?.src).map((c) => ({ loc: c[1].src })) || []
944
- );
801
+ try {
802
+ const content = ctx.content;
803
+ nuxtV3Collections.add(ctx.collection.name);
804
+ if (String(ctx.content.path).includes("/.")) {
805
+ ctx.content.sitemap = null;
806
+ return;
807
+ }
808
+ if (!ctx.collection.fields || !("sitemap" in ctx.collection.fields)) {
809
+ ctx.content.sitemap = null;
810
+ return;
811
+ }
812
+ if (typeof content.sitemap !== "undefined" && !content.sitemap) {
813
+ ctx.content.sitemap = null;
814
+ return;
815
+ }
816
+ if (ctx.content.robots === false) {
817
+ ctx.content.sitemap = null;
818
+ return;
819
+ }
820
+ const images = [];
821
+ if (config.discoverImages) {
822
+ images.push(
823
+ ...content.body?.value?.filter(
824
+ (c) => ["image", "img", "nuxtimg", "nuxt-img"].includes(c[0])
825
+ ).filter((c) => c[1]?.src).map((c) => ({ loc: c[1].src })) || []
826
+ );
827
+ }
828
+ const lastmod = content.seo?.articleModifiedTime || content.updatedAt;
829
+ const defaults = {
830
+ loc: content.path
831
+ };
832
+ if (images.length > 0)
833
+ defaults.images = images;
834
+ if (lastmod)
835
+ defaults.lastmod = lastmod;
836
+ ctx.content.sitemap = defu(typeof content.sitemap === "object" ? content.sitemap : {}, defaults);
837
+ } catch (e) {
838
+ logger.warn(`Failed to process sitemap data for content file (collection: ${ctx.collection?.name}, path: ${ctx.content?.path}), skipping.`, e);
945
839
  }
946
- const lastmod = content.seo?.articleModifiedTime || content.updatedAt;
947
- const defaults = {
948
- loc: content.path
949
- };
950
- if (images.length > 0)
951
- defaults.images = images;
952
- if (lastmod)
953
- defaults.lastmod = lastmod;
954
- ctx.content.sitemap = defu(typeof content.sitemap === "object" ? content.sitemap : {}, defaults);
955
840
  });
956
841
  nuxt.hook("nitro:config", (nitroConfig) => {
957
842
  const filterEntries = [];
@@ -981,7 +866,7 @@ ${onUrlEntries.join("\n")}`;
981
866
  context: {
982
867
  name: "@nuxt/content@v3:urls",
983
868
  description: "Generated from your markdown files.",
984
- tips: [`Parsing the following collections: ${Array.from(nuxtV3Collections).join(", ")}`]
869
+ tips: nuxtV3Collections.size ? [`Parsing the following collections: ${Array.from(nuxtV3Collections).join(", ")}`] : ["No collections found. Make sure your content collections have a `path` field."]
985
870
  },
986
871
  fetch: "/__sitemap__/nuxt-content-urls.json"
987
872
  });
@@ -1200,6 +1085,12 @@ ${onUrlEntries.join("\n")}`;
1200
1085
  route: "/__sitemap__/debug.json",
1201
1086
  handler: resolve("./runtime/server/routes/__sitemap__/debug")
1202
1087
  });
1088
+ if (nuxt.options.dev) {
1089
+ addServerHandler({
1090
+ route: "/__sitemap__/debug-production.json",
1091
+ handler: resolve("./runtime/server/routes/__sitemap__/debug-production")
1092
+ });
1093
+ }
1203
1094
  if (usingMultiSitemaps) {
1204
1095
  addServerHandler({
1205
1096
  route: "/__sitemap__/**:sitemap",
@@ -1366,7 +1257,7 @@ export async function readSourcesFromFilesystem() {
1366
1257
  }
1367
1258
  `;
1368
1259
  }
1369
- if (prerenderSitemap) {
1260
+ if (prerenderSitemap && !nuxt.options.dev) {
1370
1261
  nitroConfig.virtual["#sitemap-virtual/global-sources.mjs"] = `export const sources = []`;
1371
1262
  nitroConfig.virtual[`#sitemap-virtual/child-sources.mjs`] = `export const sources = {}`;
1372
1263
  } else {