@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
@@ -1,7 +1,8 @@
1
- import { createDefu } from "defu";
2
- import { parseURL, withLeadingSlash } from "ufo";
3
- import { createRouter, toRouteMatcher } from "radix3";
4
1
  import { createConsola } from "consola";
2
+ import { createDefu } from "defu";
3
+ import { createFilter } from "nuxtseo-shared/utils";
4
+ import { parseURL, withLeadingSlash, withoutBase } from "ufo";
5
+ export { createFilter } from "nuxtseo-shared/utils";
5
6
  export const logger = createConsola({
6
7
  defaults: {
7
8
  tag: "@nuxt/sitemap"
@@ -46,8 +47,12 @@ export function normalizeRuntimeFilters(input) {
46
47
  return false;
47
48
  }).filter(Boolean);
48
49
  }
49
- export function createPathFilter(options = {}) {
50
- const urlFilter = createFilter(options);
50
+ export function createPathFilter(options = {}, baseURL) {
51
+ const urlFilter = createFilter({
52
+ include: normalizeRuntimeFilters(options.include),
53
+ exclude: normalizeRuntimeFilters(options.exclude)
54
+ });
55
+ const hasBase = baseURL && baseURL !== "/";
51
56
  return (loc) => {
52
57
  let path = loc;
53
58
  try {
@@ -55,6 +60,8 @@ export function createPathFilter(options = {}) {
55
60
  } catch {
56
61
  return false;
57
62
  }
63
+ if (hasBase)
64
+ path = withoutBase(path, baseURL);
58
65
  return urlFilter(path);
59
66
  };
60
67
  }
@@ -65,7 +72,7 @@ export function findPageMapping(pathWithoutPrefix, pages) {
65
72
  return { mappings: pages[pageKey], paramSegments: [] };
66
73
  const sortedKeys = Object.keys(pages).sort((a, b) => b.length - a.length);
67
74
  for (const key of sortedKeys) {
68
- if (pageKey.startsWith(key + "/")) {
75
+ if (pageKey.startsWith(`${key}/`)) {
69
76
  const paramPath = pageKey.slice(key.length + 1);
70
77
  return { mappings: pages[key], paramSegments: paramPath.split("/") };
71
78
  }
@@ -78,38 +85,3 @@ export function applyDynamicParams(customPath, paramSegments) {
78
85
  let i = 0;
79
86
  return customPath.replace(/\[[^\]]+\]/g, () => paramSegments[i++] || "");
80
87
  }
81
- export function createFilter(options = {}) {
82
- const include = options.include || [];
83
- const exclude = options.exclude || [];
84
- if (include.length === 0 && exclude.length === 0)
85
- return () => true;
86
- const excludeRegex = exclude.filter((r) => r instanceof RegExp);
87
- const includeRegex = include.filter((r) => r instanceof RegExp);
88
- const excludeStrings = exclude.filter((r) => typeof r === "string");
89
- const includeStrings = include.filter((r) => typeof r === "string");
90
- const excludeMatcher = excludeStrings.length > 0 ? toRouteMatcher(createRouter({
91
- routes: Object.fromEntries(excludeStrings.map((r) => [r, true])),
92
- strictTrailingSlash: false
93
- })) : null;
94
- const includeMatcher = includeStrings.length > 0 ? toRouteMatcher(createRouter({
95
- routes: Object.fromEntries(includeStrings.map((r) => [r, true])),
96
- strictTrailingSlash: false
97
- })) : null;
98
- const excludeExact = new Set(excludeStrings);
99
- const includeExact = new Set(includeStrings);
100
- return function(path) {
101
- if (excludeRegex.some((r) => r.test(path)))
102
- return false;
103
- if (excludeExact.has(path))
104
- return false;
105
- if (excludeMatcher && excludeMatcher.matchAll(path).length > 0)
106
- return false;
107
- if (includeRegex.some((r) => r.test(path)))
108
- return true;
109
- if (includeExact.has(path))
110
- return true;
111
- if (includeMatcher && includeMatcher.matchAll(path).length > 0)
112
- return true;
113
- return include.length === 0;
114
- };
115
- }
@@ -2,9 +2,11 @@ import { parseURL } from 'ufo';
2
2
  import { parse, walkSync, ELEMENT_NODE } from 'ultrahtml';
3
3
 
4
4
  function isValidUrl(url) {
5
- if (!url || typeof url !== "string") return false;
5
+ if (!url || typeof url !== "string")
6
+ return false;
6
7
  const trimmed = url.trim();
7
- if (!trimmed) return false;
8
+ if (!trimmed)
9
+ return false;
8
10
  if (trimmed.startsWith("data:") || trimmed.startsWith("blob:") || trimmed.startsWith("file:")) {
9
11
  return false;
10
12
  }
@@ -19,11 +21,13 @@ function isValidString(value) {
19
21
  return typeof value === "string" && value.trim().length > 0;
20
22
  }
21
23
  function sanitizeString(value) {
22
- if (!isValidString(value)) return "";
24
+ if (!isValidString(value))
25
+ return "";
23
26
  return String(value).trim().replace(/[\x00-\x1F\x7F-\x9F]/g, "");
24
27
  }
25
28
  function isValidDate(dateString) {
26
- if (!dateString) return false;
29
+ if (!dateString)
30
+ return false;
27
31
  const date = new Date(dateString);
28
32
  return !Number.isNaN(date.getTime()) && date.getFullYear() > 1900 && date.getFullYear() < 3e3;
29
33
  }
@@ -180,7 +184,7 @@ function parseHtmlExtractSitemapMeta(html, options) {
180
184
  }
181
185
  });
182
186
  if (options?.images && images.size > 0) {
183
- payload.images = [...images].map((i) => ({ loc: i }));
187
+ payload.images = Array.from(images, (i) => ({ loc: i }));
184
188
  }
185
189
  if (options?.videos) {
186
190
  const processedVideos = [];
package/dist/utils.d.mts CHANGED
@@ -1,6 +1,14 @@
1
- import { SitemapUrlInput, SitemapUrl } from '../dist/runtime/types.js';
1
+ import { SitemapUrl, SitemapUrlInput } from '../dist/runtime/types.js';
2
2
  export * from '../dist/runtime/types.js';
3
3
 
4
+ declare function parseHtmlExtractSitemapMeta(html: string, options?: {
5
+ images?: boolean;
6
+ videos?: boolean;
7
+ lastmod?: boolean;
8
+ alternatives?: boolean;
9
+ resolveUrl?: (s: string) => string;
10
+ }): Partial<SitemapUrl> | null;
11
+
4
12
  interface SitemapWarning {
5
13
  type: 'validation';
6
14
  message: string;
@@ -27,13 +35,5 @@ interface SitemapIndexParseResult {
27
35
  declare function parseSitemapIndex(xml: string): SitemapIndexParseResult;
28
36
  declare function isSitemapIndex(xml: string): boolean;
29
37
 
30
- declare function parseHtmlExtractSitemapMeta(html: string, options?: {
31
- images?: boolean;
32
- videos?: boolean;
33
- lastmod?: boolean;
34
- alternatives?: boolean;
35
- resolveUrl?: (s: string) => string;
36
- }): Partial<SitemapUrl> | null;
37
-
38
38
  export { isSitemapIndex, parseHtmlExtractSitemapMeta, parseSitemapIndex, parseSitemapXml };
39
39
  export type { SitemapIndexEntry, SitemapIndexParseResult, SitemapParseResult, SitemapWarning };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,14 @@
1
- import { SitemapUrlInput, SitemapUrl } from '../dist/runtime/types.js';
1
+ import { SitemapUrl, SitemapUrlInput } from '../dist/runtime/types.js';
2
2
  export * from '../dist/runtime/types.js';
3
3
 
4
+ declare function parseHtmlExtractSitemapMeta(html: string, options?: {
5
+ images?: boolean;
6
+ videos?: boolean;
7
+ lastmod?: boolean;
8
+ alternatives?: boolean;
9
+ resolveUrl?: (s: string) => string;
10
+ }): Partial<SitemapUrl> | null;
11
+
4
12
  interface SitemapWarning {
5
13
  type: 'validation';
6
14
  message: string;
@@ -27,13 +35,5 @@ interface SitemapIndexParseResult {
27
35
  declare function parseSitemapIndex(xml: string): SitemapIndexParseResult;
28
36
  declare function isSitemapIndex(xml: string): boolean;
29
37
 
30
- declare function parseHtmlExtractSitemapMeta(html: string, options?: {
31
- images?: boolean;
32
- videos?: boolean;
33
- lastmod?: boolean;
34
- alternatives?: boolean;
35
- resolveUrl?: (s: string) => string;
36
- }): Partial<SitemapUrl> | null;
37
-
38
38
  export { isSitemapIndex, parseHtmlExtractSitemapMeta, parseSitemapIndex, parseSitemapXml };
39
39
  export type { SitemapIndexEntry, SitemapIndexParseResult, SitemapParseResult, SitemapWarning };
package/dist/utils.mjs CHANGED
@@ -1,13 +1,61 @@
1
+ export { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.B99ug6A9.mjs';
1
2
  import { XMLParser } from 'fast-xml-parser';
2
- export { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.Bj0OAEtK.mjs';
3
3
  import 'ufo';
4
4
  import 'ultrahtml';
5
5
 
6
+ const parser = new XMLParser({
7
+ isArray: (tagName) => tagName === "sitemap",
8
+ removeNSPrefix: true,
9
+ trimValues: true
10
+ });
11
+ function isValidUrl(value) {
12
+ return URL.canParse(value);
13
+ }
14
+ function parseSitemapIndex(xml) {
15
+ if (!xml)
16
+ throw new Error("Empty XML input provided");
17
+ const parsed = parser.parse(xml);
18
+ if (parsed?.sitemapindex === void 0)
19
+ throw new Error("XML does not contain a valid sitemapindex element");
20
+ if (!parsed.sitemapindex || !parsed.sitemapindex.sitemap)
21
+ return { entries: [], warnings: [] };
22
+ const sitemaps = Array.isArray(parsed.sitemapindex.sitemap) ? parsed.sitemapindex.sitemap : [parsed.sitemapindex.sitemap];
23
+ const warnings = [];
24
+ const entries = [];
25
+ for (const s of sitemaps) {
26
+ if (typeof s.loc !== "string" || !s.loc.trim().length) {
27
+ warnings.push({
28
+ type: "validation",
29
+ message: "Sitemap entry missing required loc element"
30
+ });
31
+ continue;
32
+ }
33
+ const loc = s.loc.trim();
34
+ if (!isValidUrl(loc)) {
35
+ warnings.push({
36
+ type: "validation",
37
+ message: "Sitemap entry has invalid URL",
38
+ context: { url: loc }
39
+ });
40
+ continue;
41
+ }
42
+ entries.push({
43
+ loc,
44
+ ...s.lastmod && { lastmod: s.lastmod.trim() }
45
+ });
46
+ }
47
+ return { entries, warnings };
48
+ }
49
+ function isSitemapIndex(xml) {
50
+ return xml.includes("<sitemapindex") || xml.includes("sitemapindex>");
51
+ }
52
+
6
53
  function isValidString(value) {
7
54
  return typeof value === "string" && value.trim().length > 0;
8
55
  }
9
56
  function parseNumber(value) {
10
- if (typeof value === "number") return value;
57
+ if (typeof value === "number")
58
+ return value;
11
59
  if (typeof value === "string" && value.trim()) {
12
60
  const num = Number.parseFloat(value.trim());
13
61
  return Number.isNaN(num) ? void 0 : num;
@@ -15,7 +63,8 @@ function parseNumber(value) {
15
63
  return void 0;
16
64
  }
17
65
  function parseInteger(value) {
18
- if (typeof value === "number") return Math.floor(value);
66
+ if (typeof value === "number")
67
+ return Math.floor(value);
19
68
  if (typeof value === "string" && value.trim()) {
20
69
  const num = Number.parseInt(value.trim(), 10);
21
70
  return Number.isNaN(num) ? void 0 : num;
@@ -86,10 +135,14 @@ function extractUrlFromParsedElement(urlElement, warnings) {
86
135
  const videos = Array.isArray(urlElement.video) ? urlElement.video : [urlElement.video];
87
136
  const validVideos = videos.map((video) => {
88
137
  const missingFields = [];
89
- if (!isValidString(video.title)) missingFields.push("title");
90
- if (!isValidString(video.thumbnail_loc)) missingFields.push("thumbnail_loc");
91
- if (!isValidString(video.description)) missingFields.push("description");
92
- if (!isValidString(video.content_loc)) missingFields.push("content_loc");
138
+ if (!isValidString(video.title))
139
+ missingFields.push("title");
140
+ if (!isValidString(video.thumbnail_loc))
141
+ missingFields.push("thumbnail_loc");
142
+ if (!isValidString(video.description))
143
+ missingFields.push("description");
144
+ if (!isValidString(video.content_loc))
145
+ missingFields.push("content_loc");
93
146
  if (missingFields.length > 0) {
94
147
  warnings.push({
95
148
  type: "validation",
@@ -365,56 +418,4 @@ async function parseSitemapXml(xml) {
365
418
  }
366
419
  }
367
420
 
368
- const parser = new XMLParser({
369
- isArray: (tagName) => tagName === "sitemap",
370
- removeNSPrefix: true,
371
- trimValues: true
372
- });
373
- function isValidUrl(value) {
374
- try {
375
- new URL(value);
376
- return true;
377
- } catch {
378
- return false;
379
- }
380
- }
381
- function parseSitemapIndex(xml) {
382
- if (!xml)
383
- throw new Error("Empty XML input provided");
384
- const parsed = parser.parse(xml);
385
- if (parsed?.sitemapindex === void 0)
386
- throw new Error("XML does not contain a valid sitemapindex element");
387
- if (!parsed.sitemapindex || !parsed.sitemapindex.sitemap)
388
- return { entries: [], warnings: [] };
389
- const sitemaps = Array.isArray(parsed.sitemapindex.sitemap) ? parsed.sitemapindex.sitemap : [parsed.sitemapindex.sitemap];
390
- const warnings = [];
391
- const entries = [];
392
- for (const s of sitemaps) {
393
- if (typeof s.loc !== "string" || !s.loc.trim().length) {
394
- warnings.push({
395
- type: "validation",
396
- message: "Sitemap entry missing required loc element"
397
- });
398
- continue;
399
- }
400
- const loc = s.loc.trim();
401
- if (!isValidUrl(loc)) {
402
- warnings.push({
403
- type: "validation",
404
- message: "Sitemap entry has invalid URL",
405
- context: { url: loc }
406
- });
407
- continue;
408
- }
409
- entries.push({
410
- loc,
411
- ...s.lastmod && { lastmod: s.lastmod.trim() }
412
- });
413
- }
414
- return { entries, warnings };
415
- }
416
- function isSitemapIndex(xml) {
417
- return xml.includes("<sitemapindex") || xml.includes("sitemapindex>");
418
- }
419
-
420
421
  export { isSitemapIndex, parseSitemapIndex, parseSitemapXml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/sitemap",
3
3
  "type": "module",
4
- "version": "7.6.0",
4
+ "version": "8.0.1",
5
5
  "description": "Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -18,9 +18,6 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/nuxt-modules/sitemap/issues"
20
20
  },
21
- "engines": {
22
- "node": ">=18.0.0"
23
- },
24
21
  "exports": {
25
22
  ".": {
26
23
  "types": "./dist/types.d.mts",
@@ -30,9 +27,6 @@
30
27
  "./utils": "./dist/utils.mjs"
31
28
  },
32
29
  "main": "./dist/module.mjs",
33
- "files": [
34
- "dist"
35
- ],
36
30
  "typesVersions": {
37
31
  "*": {
38
32
  ".": [
@@ -46,66 +40,73 @@
46
40
  ]
47
41
  }
48
42
  },
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "peerDependencies": {
50
+ "zod": ">=3"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "zod": {
54
+ "optional": true
55
+ }
56
+ },
49
57
  "dependencies": {
50
- "@nuxt/devtools-kit": "^3.1.1",
51
- "@nuxt/kit": "^4.3.0",
52
- "chalk": "^5.6.2",
58
+ "@nuxt/devtools-kit": "4.0.0-alpha.3",
59
+ "@nuxt/kit": "^4.4.2",
60
+ "consola": "^3.4.2",
53
61
  "defu": "^6.1.4",
54
- "fast-xml-parser": "^5.3.3",
55
- "nuxt-site-config": "^3.2.18",
62
+ "fast-xml-parser": "^5.5.9",
63
+ "nuxt-site-config": "^4.0.0",
64
+ "nuxtseo-layer-devtools": "^0.3.0",
65
+ "nuxtseo-shared": "^0.7.0",
56
66
  "ofetch": "^1.5.1",
57
67
  "pathe": "^2.0.3",
58
68
  "pkg-types": "^2.3.0",
59
69
  "radix3": "^1.1.2",
60
- "semver": "^7.7.3",
70
+ "semver": "^7.7.4",
61
71
  "sirv": "^3.0.2",
62
- "std-env": "^3.10.0",
72
+ "std-env": "^4.0.0",
63
73
  "ufo": "^1.6.3",
64
74
  "ultrahtml": "^1.6.0"
65
75
  },
66
- "peerDependencies": {
67
- "zod": ">=3"
68
- },
69
- "peerDependenciesMeta": {
70
- "zod": {
71
- "optional": true
72
- }
73
- },
74
76
  "devDependencies": {
77
+ "@antfu/eslint-config": "^7.7.3",
75
78
  "@arethetypeswrong/cli": "^0.18.2",
76
- "@nuxt/content": "^3.11.0",
77
- "@nuxt/eslint-config": "^1.13.0",
79
+ "@nuxt/content": "^3.12.0",
78
80
  "@nuxt/module-builder": "^1.0.2",
79
- "@nuxt/test-utils": "^3.23.0",
80
- "@nuxt/ui": "^4.4.0",
81
- "@nuxtjs/i18n": "^10.2.1",
82
- "@nuxtjs/robots": "^5.6.7",
81
+ "@nuxt/test-utils": "^4.0.0",
82
+ "@nuxt/ui": "^4.6.0",
83
+ "@nuxtjs/i18n": "^10.2.4",
84
+ "@nuxtjs/robots": "^6.0.0-beta.2",
83
85
  "@vue/test-utils": "^2.4.6",
84
- "better-sqlite3": "^12.6.2",
85
- "bumpp": "^10.4.0",
86
- "eslint": "^9.39.2",
87
- "eslint-plugin-n": "^17.23.2",
86
+ "better-sqlite3": "^12.8.0",
87
+ "bumpp": "^11.0.1",
88
+ "eslint": "^10.1.0",
89
+ "eslint-plugin-harlanzw": "^0.11.0",
88
90
  "execa": "^9.6.1",
89
- "happy-dom": "^20.3.9",
90
- "nuxt": "^4.3.0",
91
- "nuxt-i18n-micro": "^2.20.1",
92
- "typescript": "^5.9.3",
93
- "vitest": "3.2.4",
94
- "vue-tsc": "^3.2.4",
91
+ "happy-dom": "^20.8.7",
92
+ "nuxt": "^4.4.2",
93
+ "nuxt-i18n-micro": "^3.13.4",
94
+ "typescript": "^6.0.2",
95
+ "vitest": "^4.1.1",
96
+ "vue-tsc": "^3.2.6",
95
97
  "zod": "^4.3.6",
96
- "@nuxtjs/sitemap": "7.6.0"
98
+ "@nuxtjs/sitemap": "8.0.1"
97
99
  },
98
100
  "scripts": {
99
101
  "lint": "eslint .",
100
- "lint:type": "tsc --noEmit",
101
102
  "lint:fix": "eslint . --fix",
102
- "client:build": "nuxi generate client",
103
- "client:dev": "nuxi dev client --port 3300",
103
+ "client:build": "nuxt generate devtools",
104
+ "devtools": "nuxt dev devtools --port 3030",
104
105
  "build": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && npm run client:build",
105
- "dev": "nuxi dev playground",
106
- "prepare:fixtures": "nuxi prepare test/fixtures/basic && nuxi prepare test/fixtures/i18n && nuxi prepare test/fixtures/i18n-micro",
107
- "dev:build": "nuxi build playground",
108
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
106
+ "dev": "nuxt dev playground",
107
+ "prepare:fixtures": "nuxt prepare test/fixtures/basic && nuxt prepare test/fixtures/i18n && nuxt prepare test/fixtures/i18n-micro",
108
+ "dev:build": "nuxt build playground",
109
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
109
110
  "release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
110
111
  "test": "vitest run && pnpm run test:attw",
111
112
  "test:unit": "vitest --project=unit",
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__sitemap__/devtools/_nuxt/entry.D1qdnVLM.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BaarzCY9.js"><script type="module" src="/__sitemap__/devtools/_nuxt/BaarzCY9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT_SITE_CONFIG__={_priority:{name:-10,env:-15},env:"production",name:"@nuxtjs\u002Fsitemap-client"}</script><script>window.__NUXT__={};window.__NUXT__.config={public:{mdc:{components:{prose:true,map:{},customElements:[]},headings:{anchorLinks:{h1:false,h2:true,h3:true,h4:true,h5:false,h6:false}},highlight:{noApiRoute:true,highlighter:"shiki",theme:{default:"github-light",dark:"github-dark"},shikiEngine:"oniguruma",langs:["js","jsx","json","ts","tsx","vue","css","html","bash","md","mdc","yaml"]}}},app:{baseURL:"/__sitemap__/devtools",buildId:"6319eec7-8aee-40f4-abcf-31c51d4b20a5",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1769581071882,false]</script></body></html>
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__sitemap__/devtools/_nuxt/entry.D1qdnVLM.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BaarzCY9.js"><script type="module" src="/__sitemap__/devtools/_nuxt/BaarzCY9.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT_SITE_CONFIG__={_priority:{name:-10,env:-15},env:"production",name:"@nuxtjs\u002Fsitemap-client"}</script><script>window.__NUXT__={};window.__NUXT__.config={public:{mdc:{components:{prose:true,map:{},customElements:[]},headings:{anchorLinks:{h1:false,h2:true,h3:true,h4:true,h5:false,h6:false}},highlight:{noApiRoute:true,highlighter:"shiki",theme:{default:"github-light",dark:"github-dark"},shikiEngine:"oniguruma",langs:["js","jsx","json","ts","tsx","vue","css","html","bash","md","mdc","yaml"]}}},app:{baseURL:"/__sitemap__/devtools",buildId:"6319eec7-8aee-40f4-abcf-31c51d4b20a5",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1769581071883,false]</script></body></html>
@@ -1 +0,0 @@
1
- import{_ as r,c as s,o,r as n}from"./BaarzCY9.js";const t={};function c(e,a){return o(),s("p",null,[n(e.$slots,"default")])}const l=Object.assign(r(t,[["render",c]]),{__name:"ProseP"});export{l as default};
@@ -1 +0,0 @@
1
- import{_ as o,c as r,o as s,r as c}from"./BaarzCY9.js";const n={};function t(e,a){return s(),r("code",null,[c(e.$slots,"default")])}const l=Object.assign(o(n,[["render",t]]),{__name:"ProseCode"});export{l as default};
@@ -1 +0,0 @@
1
- import{g as c,c as t,o as n,r,h as d,i as h}from"./BaarzCY9.js";const p=["id"],u=["href"],k={__name:"ProseH2",props:{id:{type:String,required:!1}},setup(a){const e=a,{headings:o}=c().public.mdc,i=h(()=>e.id&&(typeof o?.anchorLinks=="boolean"&&o?.anchorLinks===!0||typeof o?.anchorLinks=="object"&&o?.anchorLinks?.h2));return(s,f)=>(n(),t("h2",{id:e.id},[e.id&&d(i)?(n(),t("a",{key:0,href:`#${e.id}`},[r(s.$slots,"default")],8,u)):r(s.$slots,"default",{key:1})],8,p))}};export{k as default};
@@ -1 +0,0 @@
1
- import{g as c,c as t,o as n,r,h as d,i as h}from"./BaarzCY9.js";const p=["id"],u=["href"],k={__name:"ProseH5",props:{id:{type:String,required:!1}},setup(a){const e=a,{headings:o}=c().public.mdc,i=h(()=>e.id&&(typeof o?.anchorLinks=="boolean"&&o?.anchorLinks===!0||typeof o?.anchorLinks=="object"&&o?.anchorLinks?.h5));return(s,f)=>(n(),t("h5",{id:e.id},[e.id&&d(i)?(n(),t("a",{key:0,href:`#${e.id}`},[r(s.$slots,"default")],8,u)):r(s.$slots,"default",{key:1})],8,p))}};export{k as default};
@@ -1 +0,0 @@
1
- import{f as o,o as n,w as s,r as f,e as p}from"./BaarzCY9.js";const u={__name:"ProseA",props:{href:{type:String,default:""},target:{type:String,default:void 0,required:!1}},setup(e){const t=e;return(r,_)=>{const a=p;return n(),o(a,{href:t.href,target:t.target},{default:s(()=>[f(r.$slots,"default")]),_:3},8,["href","target"])}}};export{u as default};