@nuxtjs/sitemap 8.3.2 → 8.3.4

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 (53) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +53 -70
  3. package/dist/runtime/server/composables/defineSitemapEventHandler.d.ts +2 -2
  4. package/dist/runtime/server/composables/defineSitemapEventHandler.js +1 -1
  5. package/dist/runtime/server/plugins/compression.d.ts +1 -1
  6. package/dist/runtime/server/plugins/compression.js +2 -2
  7. package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +1 -1
  8. package/dist/runtime/server/plugins/nuxt-content-v2.js +1 -1
  9. package/dist/runtime/server/plugins/stream-transport.d.ts +1 -1
  10. package/dist/runtime/server/plugins/stream-transport.js +2 -2
  11. package/dist/runtime/server/plugins/warm-up.d.ts +1 -1
  12. package/dist/runtime/server/plugins/warm-up.js +1 -1
  13. package/dist/runtime/server/robots-polyfill/getPathRobotConfig.d.ts +1 -1
  14. package/dist/runtime/server/routes/__sitemap__/debug-production.d.ts +1 -1
  15. package/dist/runtime/server/routes/__sitemap__/debug-production.js +1 -1
  16. package/dist/runtime/server/routes/__sitemap__/debug.d.ts +1 -46
  17. package/dist/runtime/server/routes/__sitemap__/debug.js +1 -1
  18. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.d.ts +1 -1
  19. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.js +1 -1
  20. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.d.ts +1 -1
  21. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.js +1 -1
  22. package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.d.ts +1 -1
  23. package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.js +1 -1
  24. package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.d.ts +1 -1
  25. package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.js +1 -1
  26. package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.d.ts +1 -1
  27. package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.js +1 -1
  28. package/dist/runtime/server/routes/sitemap/[sitemap].xml.d.ts +1 -1
  29. package/dist/runtime/server/routes/sitemap/[sitemap].xml.js +1 -1
  30. package/dist/runtime/server/routes/sitemap.xml.d.ts +1 -1
  31. package/dist/runtime/server/routes/sitemap.xml.js +1 -1
  32. package/dist/runtime/server/routes/sitemap.xsl.d.ts +1 -1
  33. package/dist/runtime/server/routes/sitemap.xsl.js +1 -1
  34. package/dist/runtime/server/routes/sitemap_index.xml.d.ts +1 -1
  35. package/dist/runtime/server/routes/sitemap_index.xml.js +1 -1
  36. package/dist/runtime/server/sitemap/builder/entries.d.ts +7 -0
  37. package/dist/runtime/server/sitemap/builder/entries.js +100 -0
  38. package/dist/runtime/server/sitemap/builder/sitemap-index.d.ts +3 -9
  39. package/dist/runtime/server/sitemap/builder/sitemap-index.js +2 -2
  40. package/dist/runtime/server/sitemap/builder/sitemap.d.ts +3 -10
  41. package/dist/runtime/server/sitemap/builder/sitemap.js +5 -163
  42. package/dist/runtime/server/sitemap/event-handlers.d.ts +2 -2
  43. package/dist/runtime/server/sitemap/event-handlers.js +2 -2
  44. package/dist/runtime/server/sitemap/nitro.d.ts +4 -2
  45. package/dist/runtime/server/sitemap/nitro.js +2 -2
  46. package/dist/runtime/server/sitemap/urlset/sources.d.ts +1 -1
  47. package/dist/runtime/server/sitemap/urlset/sources.js +5 -4
  48. package/dist/runtime/server/utils.d.ts +1 -1
  49. package/dist/runtime/server/utils.js +1 -1
  50. package/dist/runtime/types.d.ts +7 -7
  51. package/dist/runtime/utils-pure.d.ts +7 -7
  52. package/dist/runtime/utils-pure.js +44 -22
  53. package/package.json +19 -18
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.9.0"
5
5
  },
6
6
  "configKey": "sitemap",
7
- "version": "8.3.2",
7
+ "version": "8.3.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -2,11 +2,11 @@ import { useNuxt, hasNuxtModule, addTypeTemplate, addTemplate, defineNuxtModule,
2
2
  import { defu } from 'defu';
3
3
  import { withSiteUrl, installNuxtSiteConfig } from 'nuxt-site-config/kit';
4
4
  import { isPathFile } from 'nuxt-site-config/urls';
5
- import { isNuxtGenerate, useModuleLogger, getNuxtModuleOptions, resolveNitroPreset, resolveNuxtContentVersion, createPagesPromise, createNitroPromise } from 'nuxtseo-shared/kit';
5
+ import { isNuxtGenerate, renderNitroTypeAugmentations, useModuleLogger, setupNitroRuntimeCompatibility, getNuxtModuleOptions, resolveNitroPreset, resolveNuxtContentVersion, createPagesPromise, createNitroPromise } from 'nuxtseo-shared/kit';
6
6
  import { serializeFilters } from 'nuxtseo-shared/utils';
7
7
  import { dirname, extname } from 'pathe';
8
8
  import { readPackageJSON } from 'pkg-types';
9
- import { withBase, withHttps, withTrailingSlash, withoutLeadingSlash, joinURL, withLeadingSlash, withoutTrailingSlash } from 'ufo';
9
+ import { withBase, withHttps, withTrailingSlash, withoutLeadingSlash, joinURL, withLeadingSlash } from 'ufo';
10
10
  import { setupDevToolsUI as setupDevToolsUI$1 } from 'nuxtseo-shared/devtools';
11
11
  import { readFileSync, statSync } from 'node:fs';
12
12
  import { mkdir, writeFile } from 'node:fs/promises';
@@ -15,7 +15,7 @@ import { colors } from 'consola/utils';
15
15
  import { splitForLocales, createPathFilter } from '../dist/runtime/utils-pure.js';
16
16
  import { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.BoMnWHOt.mjs';
17
17
  import { normaliseDate } from '../dist/runtime/server/sitemap/urlset/normalise.js';
18
- import { splitPathForI18nLocales as splitPathForI18nLocales$1, expandCompactLocaleRoute, normalizeLocales, generatePathForI18nPages } from 'nuxtseo-shared/i18n';
18
+ import { mapPathForI18nPages, splitPathForI18nLocales as splitPathForI18nLocales$1, expandCompactLocaleRoute, normalizeLocales, generatePathForI18nPages } from 'nuxtseo-shared/i18n';
19
19
  import 'ultrahtml';
20
20
 
21
21
  function setupDevToolsUI(_options, resolve, nuxt = useNuxt()) {
@@ -174,53 +174,31 @@ async function prerenderRoute(nitro, route) {
174
174
  return { filePath, prerenderUrls };
175
175
  }
176
176
 
177
- function registerTypeTemplates() {
177
+ function registerTypeTemplates(nitroCompatibility) {
178
178
  const hasRobotsModule = hasNuxtModule("@nuxtjs/robots") || hasNuxtModule("nuxt-simple-robots");
179
179
  addTypeTemplate({
180
180
  filename: "types/nuxt-sitemap-augments.d.ts",
181
181
  getContents: () => {
182
- const robotsType = hasRobotsModule ? "" : " robots?: boolean\n";
182
+ const robotsType = hasRobotsModule ? "" : "robots?: boolean\n";
183
+ const routeRules = `${robotsType}sitemap?: SitemapItemDefaults | false`;
184
+ const runtimeHooks = `'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
185
+ 'sitemap:input': (ctx: SitemapInputCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
186
+ 'sitemap:resolved': (ctx: SitemapRenderCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
187
+ 'sitemap:output': (ctx: SitemapOutputHookCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
188
+ 'sitemap:sources': (ctx: SitemapSourcesHookCtx<${nitroCompatibility.eventType}>) => void | Promise<void>`;
189
+ const nitroTypes = renderNitroTypeAugmentations(nitroCompatibility, {
190
+ nitroInterfaces: {
191
+ PrerenderRoute: "_sitemap?: SitemapUrl"
192
+ },
193
+ routeConfig: routeRules,
194
+ routeRules,
195
+ runtimeHooks
196
+ });
183
197
  return `// Generated by @nuxtjs/sitemap
184
198
  /// <reference path="./nuxt-sitemap-virtual.d.ts" />
185
199
  import type { SitemapUrl, SitemapItemDefaults, SitemapIndexRenderCtx, SitemapInputCtx, SitemapRenderCtx, SitemapOutputHookCtx, SitemapSourcesHookCtx } from '@nuxtjs/sitemap'
186
200
 
187
- declare module 'nitropack' {
188
- interface PrerenderRoute {
189
- _sitemap?: SitemapUrl
190
- }
191
- interface NitroRouteRules {
192
- ${robotsType} sitemap?: SitemapItemDefaults | false
193
- }
194
- interface NitroRouteConfig {
195
- ${robotsType} sitemap?: SitemapItemDefaults | false
196
- }
197
- interface NitroRuntimeHooks {
198
- 'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
199
- 'sitemap:input': (ctx: SitemapInputCtx) => void | Promise<void>
200
- 'sitemap:resolved': (ctx: SitemapRenderCtx) => void | Promise<void>
201
- 'sitemap:output': (ctx: SitemapOutputHookCtx) => void | Promise<void>
202
- 'sitemap:sources': (ctx: SitemapSourcesHookCtx) => void | Promise<void>
203
- }
204
- }
205
-
206
- declare module 'nitropack/types' {
207
- interface PrerenderRoute {
208
- _sitemap?: SitemapUrl
209
- }
210
- interface NitroRouteRules {
211
- ${robotsType} sitemap?: SitemapItemDefaults | false
212
- }
213
- interface NitroRouteConfig {
214
- ${robotsType} sitemap?: SitemapItemDefaults | false
215
- }
216
- interface NitroRuntimeHooks {
217
- 'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
218
- 'sitemap:input': (ctx: SitemapInputCtx) => void | Promise<void>
219
- 'sitemap:resolved': (ctx: SitemapRenderCtx) => void | Promise<void>
220
- 'sitemap:output': (ctx: SitemapOutputHookCtx) => void | Promise<void>
221
- 'sitemap:sources': (ctx: SitemapSourcesHookCtx) => void | Promise<void>
222
- }
223
- }
201
+ ${nitroTypes}
224
202
 
225
203
  declare module 'vue-router' {
226
204
  interface RouteMeta {
@@ -282,6 +260,33 @@ function splitPathForI18nLocales(path, autoI18n) {
282
260
  return path;
283
261
  return splitPathForI18nLocales$1(path, autoI18n);
284
262
  }
263
+ function uniquePaths(paths) {
264
+ return [...new Set(paths)];
265
+ }
266
+ function resolveI18nFilterPaths(path, autoI18n) {
267
+ if (typeof path !== "string")
268
+ return [path];
269
+ const mappedPaths = mapPathForI18nPages(path, autoI18n);
270
+ if (mappedPaths === false) {
271
+ if (autoI18n.strategy === "no_prefix")
272
+ return [path];
273
+ const splitPaths = splitPathForI18nLocales$1(path, autoI18n);
274
+ return Array.isArray(splitPaths) ? splitPaths : [splitPaths];
275
+ }
276
+ if (autoI18n.strategy === "prefix" || autoI18n.strategy === "no_prefix")
277
+ return uniquePaths(mappedPaths);
278
+ const defaultLocales = autoI18n.locales.filter((locale) => locale.code === autoI18n.defaultLocale);
279
+ const defaultStrategy = autoI18n.strategy === "prefix_and_default" ? "prefix" : "no_prefix";
280
+ const defaultPaths = mapPathForI18nPages(path, {
281
+ ...autoI18n,
282
+ locales: defaultLocales,
283
+ strategy: defaultStrategy
284
+ });
285
+ return uniquePaths([
286
+ ...defaultPaths || [path],
287
+ ...mappedPaths
288
+ ]);
289
+ }
285
290
 
286
291
  async function resolveUrls(urls, ctx) {
287
292
  try {
@@ -518,6 +523,7 @@ const module$1 = defineNuxtModule({
518
523
  logger.debug("The module is disabled, skipping setup.");
519
524
  return;
520
525
  }
526
+ const nitroCompatibility = setupNitroRuntimeCompatibility(nuxt);
521
527
  config.exclude.push(`${withTrailingSlash(nuxt.options.app.buildAssetsDir)}**`);
522
528
  nuxt.options.alias["#sitemap"] = resolve("./runtime");
523
529
  nuxt.options.nitro.alias = nuxt.options.nitro.alias || {};
@@ -709,7 +715,7 @@ const module$1 = defineNuxtModule({
709
715
  }]);
710
716
  }
711
717
  });
712
- registerTypeTemplates();
718
+ registerTypeTemplates(nitroCompatibility);
713
719
  const prerenderedRoutes = nuxt.options.nitro.prerender?.routes || [];
714
720
  let prerenderSitemap = isNuxtGenerate() || includesSitemapRoot(config.sitemapName, prerenderedRoutes);
715
721
  if (resolveNitroPreset() === "vercel-edge") {
@@ -987,38 +993,15 @@ ${onUrlEntries.join("\n")}`;
987
993
  };
988
994
  }
989
995
  if (resolvedAutoI18n && usingI18nPages && !hasDisabledAutoI18n) {
990
- const pages = nuxtI18nConfig?.pages || {};
996
+ const i18n = resolvedAutoI18n;
991
997
  for (const sitemapName in sitemaps) {
992
- let mapToI18nPages = function(path) {
993
- if (typeof path !== "string")
994
- return [path];
995
- const withoutSlashes = withoutTrailingSlash(withoutLeadingSlash(path)).replace("/index", "");
996
- if (pages && withoutSlashes in pages) {
997
- const pageLocales = pages[withoutSlashes];
998
- if (pageLocales) {
999
- return Object.keys(pageLocales).map((localeCode) => withLeadingSlash(generatePathForI18nPages({
1000
- localeCode,
1001
- pageLocales: pageLocales[localeCode],
1002
- nuxtI18nConfig,
1003
- normalisedLocales
1004
- })));
1005
- }
1006
- }
1007
- let match = [path];
1008
- Object.values(pages).forEach((pageLocales) => {
1009
- if (pageLocales && nuxtI18nConfig.defaultLocale in pageLocales && pageLocales[nuxtI18nConfig.defaultLocale] === path)
1010
- match = Object.keys(pageLocales).map((localeCode) => withLeadingSlash(generatePathForI18nPages({ localeCode, pageLocales: pageLocales[localeCode], nuxtI18nConfig, normalisedLocales })));
1011
- });
1012
- return match;
1013
- };
1014
998
  if (["index", "chunks"].includes(sitemapName))
1015
999
  continue;
1016
1000
  const sitemap = sitemaps[sitemapName];
1017
- sitemap.include = (sitemap.include || []).flatMap((path) => mapToI18nPages(path));
1018
- sitemap.exclude = (sitemap.exclude || []).flatMap((path) => mapToI18nPages(path));
1001
+ sitemap.include = (sitemap.include || []).flatMap((path) => resolveI18nFilterPaths(path, i18n));
1002
+ sitemap.exclude = (sitemap.exclude || []).flatMap((path) => resolveI18nFilterPaths(path, i18n));
1019
1003
  }
1020
- }
1021
- if (resolvedAutoI18n && resolvedAutoI18n.locales && resolvedAutoI18n.strategy !== "no_prefix") {
1004
+ } else if (resolvedAutoI18n && resolvedAutoI18n.locales && resolvedAutoI18n.strategy !== "no_prefix") {
1022
1005
  const i18n = resolvedAutoI18n;
1023
1006
  for (const sitemapName in sitemaps) {
1024
1007
  if (["index", "chunks"].includes(sitemapName))
@@ -1,4 +1,4 @@
1
- import type { EventHandlerRequest, EventHandlerResponse } from 'h3';
1
+ import type { EventHandlerRequest, EventHandlerResponse } from '#nuxtseo/h3';
2
2
  import type { SitemapUrlInput } from '../../types.js';
3
- import { defineEventHandler } from 'h3';
3
+ import { defineEventHandler } from '#nuxtseo/h3';
4
4
  export declare const defineSitemapEventHandler: typeof defineEventHandler<EventHandlerRequest, EventHandlerResponse<SitemapUrlInput[]>>;
@@ -1,2 +1,2 @@
1
- import { defineEventHandler } from "h3";
1
+ import { defineEventHandler } from "#nuxtseo/h3";
2
2
  export const defineSitemapEventHandler = defineEventHandler;
@@ -1,2 +1,2 @@
1
- declare const _default: import("nitropack/types").NitroAppPlugin;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { appendResponseHeader, getRequestHeader, getResponseHeader, removeResponseHeader, setResponseHeader } from "h3";
2
- import { defineNitroPlugin } from "nitropack/runtime";
1
+ import { appendResponseHeader, getRequestHeader, getResponseHeader, removeResponseHeader, setResponseHeader } from "#nuxtseo/h3";
2
+ import { defineNitroPlugin } from "#nuxtseo/nitro";
3
3
  import { logger } from "../../utils-pure.js";
4
4
  import { hasNonIdentityEncoding, isReadableStream, negotiateCompressionEncoding } from "../sitemap/stream.js";
5
5
  let warnedAboutCompressionStream = false;
@@ -1,2 +1,2 @@
1
- declare const _default: import("nitropack/types").NitroAppPlugin;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { defu } from "defu";
2
- import { defineNitroPlugin } from "nitropack/runtime";
2
+ import { defineNitroPlugin } from "#nuxtseo/nitro";
3
3
  import { useSitemapRuntimeConfig } from "../utils.js";
4
4
  export default defineNitroPlugin((nitroApp) => {
5
5
  const { discoverImages, isNuxtContentDocumentDriven } = useSitemapRuntimeConfig();
@@ -1,2 +1,2 @@
1
- declare const _default: import("nitropack/types").NitroAppPlugin;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { removeResponseHeader } from "h3";
2
- import { defineNitroPlugin } from "nitropack/runtime";
1
+ import { removeResponseHeader } from "#nuxtseo/h3";
2
+ import { defineNitroPlugin } from "#nuxtseo/nitro";
3
3
  import { logger } from "../../utils-pure.js";
4
4
  import { createNodeResponseStream, isReadableStream } from "../sitemap/stream.js";
5
5
  export default defineNitroPlugin((nitro) => {
@@ -1,2 +1,2 @@
1
- declare const _default: import("nitropack/types").NitroAppPlugin;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { defineNitroPlugin } from "nitropack/runtime";
2
1
  import { joinURL, withLeadingSlash } from "ufo";
2
+ import { defineNitroPlugin } from "#nuxtseo/nitro";
3
3
  import { useSitemapRuntimeConfig } from "../utils.js";
4
4
  export default defineNitroPlugin((nitroApp) => {
5
5
  const { sitemaps, sitemapsPathPrefix } = useSitemapRuntimeConfig();
@@ -1,4 +1,4 @@
1
- import type { H3Event } from 'h3';
1
+ import type { H3Event } from '#nuxtseo/h3';
2
2
  export declare function getPathRobotConfig(_e: H3Event, _options: any): {
3
3
  indexable: boolean;
4
4
  rule: string;
@@ -13,5 +13,5 @@ export interface ProductionDebugResponse {
13
13
  warnings: SitemapIssue[];
14
14
  error?: string;
15
15
  }
16
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Record<string, any> | ProductionDebugResponse>>;
16
+ declare const _default: any;
17
17
  export default _default;
@@ -1,5 +1,5 @@
1
- import { defineEventHandler, getQuery } from "h3";
2
1
  import { collectSitemap } from "sitemapd/parse";
2
+ import { defineEventHandler, getQuery } from "#nuxtseo/h3";
3
3
  async function fetchSitemapBody(url) {
4
4
  const response = await fetch(url, {
5
5
  headers: { Accept: "application/xml, text/xml, application/gzip" },
@@ -1,47 +1,2 @@
1
- import type { SitemapDefinition, SitemapSourceResolved } from '../../../types.js';
2
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
3
- nitroOrigin: string;
4
- sitemaps: Record<string, SitemapDefinition>;
5
- runtimeConfig: {
6
- version: string;
7
- isNuxtContentDocumentDriven: boolean;
8
- sitemaps: {
9
- index?: Pick<SitemapDefinition, "sitemapName" | "_route"> & {
10
- sitemaps: import("../../../types.js").SitemapIndexEntry[];
11
- };
12
- } & Record<string, Omit<SitemapDefinition, "urls"> & {
13
- _hasSourceChunk?: boolean;
14
- }>;
15
- autoI18n?: import("../../../types.js").AutoI18nConfig;
16
- hasDisabledAutoI18n?: boolean;
17
- isMultiSitemap: boolean;
18
- isI18nMapped: boolean;
19
- sitemapsPathPrefix: string | false;
20
- cacheMaxAgeSeconds: number | false;
21
- sitemapName: string;
22
- excludeAppSources: true | (import("../../../types.js").AppSourceContext[]);
23
- sortEntries: boolean;
24
- defaultSitemapsChunkSize: number | false;
25
- xslColumns?: {
26
- label: string;
27
- width: `${string}%`;
28
- select?: string;
29
- }[] | undefined;
30
- xslTips: boolean;
31
- debug: boolean;
32
- discoverImages: boolean;
33
- discoverVideos: boolean;
34
- autoLastmod: boolean;
35
- xsl: string | false;
36
- credits: boolean;
37
- minify: boolean;
38
- experimentalStreaming?: boolean | undefined;
39
- };
40
- globalSources: SitemapSourceResolved[];
41
- siteConfig: {
42
- [x: string]: any;
43
- [x: number]: any;
44
- url: string;
45
- };
46
- }>>;
1
+ declare const _default: any;
47
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { defineEventHandler } from "h3";
1
+ import { defineEventHandler } from "#nuxtseo/h3";
2
2
  import { getNitroOrigin, getSiteConfig } from "#site-config/server/composables";
3
3
  import { validateSitemapUrl } from "../../sitemap/urlset/normalise.js";
4
4
  import {
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown[]>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { defineEventHandler } from "h3";
2
1
  import { serverQueryContent } from "#content/server";
2
+ import { defineEventHandler } from "#nuxtseo/h3";
3
3
  export default defineEventHandler(async (e) => {
4
4
  const contentList = await serverQueryContent(e).find();
5
5
  return contentList.map((c) => c.sitemap).filter(Boolean);
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<Record<string, unknown>[]>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import { queryCollection } from "@nuxt/content/server";
2
- import { defineEventHandler } from "h3";
3
2
  import manifest from "#content/manifest";
3
+ import { defineEventHandler } from "#nuxtseo/h3";
4
4
  import { filters } from "#sitemap/content-filters";
5
5
  import { onUrlFns } from "#sitemap/content-on-url";
6
6
  export default defineEventHandler(async (e) => {
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>> | undefined>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { createError, defineEventHandler } from "h3";
1
+ import { createError, defineEventHandler } from "#nuxtseo/h3";
2
2
  export default defineEventHandler(async (e) => {
3
3
  if (import.meta.dev || import.meta.prerender) {
4
4
  const { sitemapChildXmlEventHandler } = await import("../../../sitemap/event-handlers.js");
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | void | ReadableStream<Uint8Array<ArrayBufferLike>>>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { createError, defineEventHandler } from "h3";
1
+ import { createError, defineEventHandler } from "#nuxtseo/h3";
2
2
  export default defineEventHandler(async (e) => {
3
3
  if (import.meta.dev || import.meta.prerender) {
4
4
  const { sitemapXmlEventHandler } = await import("../../sitemap/event-handlers.js");
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { createError, defineEventHandler } from "h3";
1
+ import { createError, defineEventHandler } from "#nuxtseo/h3";
2
2
  export default defineEventHandler(async (e) => {
3
3
  if (import.meta.dev || import.meta.prerender) {
4
4
  const { sitemapIndexXmlEventHandler } = await import("../../sitemap/event-handlers.js");
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>> | undefined>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { defineEventHandler } from "h3";
1
+ import { defineEventHandler } from "#nuxtseo/h3";
2
2
  import { sitemapChildXmlEventHandler } from "../../sitemap/event-handlers.js";
3
3
  export default defineEventHandler(sitemapChildXmlEventHandler);
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | void | ReadableStream<Uint8Array<ArrayBufferLike>>>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { defineEventHandler } from "h3";
1
+ import { defineEventHandler } from "#nuxtseo/h3";
2
2
  import { sitemapXmlEventHandler } from "../sitemap/event-handlers.js";
3
3
  export default defineEventHandler(sitemapXmlEventHandler);
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { defineEventHandler, getHeader, getQuery as h3GetQuery, setHeader } from "h3";
2
1
  import { getQuery, parseURL, withQuery } from "ufo";
2
+ import { defineEventHandler, getHeader, getQuery as h3GetQuery, setHeader } from "#nuxtseo/h3";
3
3
  import { getSiteConfig } from "#site-config/server/composables";
4
4
  import { createSitePathResolver } from "#site-config/server/composables/utils";
5
5
  import { useSitemapRuntimeConfig, xmlEscape } from "../utils.js";
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { defineEventHandler } from "h3";
1
+ import { defineEventHandler } from "#nuxtseo/h3";
2
2
  import { sitemapIndexXmlEventHandler } from "../sitemap/event-handlers.js";
3
3
  export default defineEventHandler(sitemapIndexXmlEventHandler);
@@ -0,0 +1,7 @@
1
+ import type { AutoI18nConfig, ModuleRuntimeConfig, NitroUrlResolvers, ResolvedSitemapUrl, SitemapDefinition, SitemapUrlInput } from '../../../types.js';
2
+ export interface NormalizedI18n extends ResolvedSitemapUrl {
3
+ _pathWithoutPrefix: string;
4
+ _locale: AutoI18nConfig['locales'][number];
5
+ _index?: number;
6
+ }
7
+ export declare function resolveSitemapEntries(sitemap: SitemapDefinition, urls: SitemapUrlInput[], runtimeConfig: Pick<ModuleRuntimeConfig, 'autoI18n' | 'isI18nMapped'>, resolvers?: NitroUrlResolvers, baseURL?: string): ResolvedSitemapUrl[];
@@ -0,0 +1,100 @@
1
+ import { createPathFilter, resolveI18nRouteEntries, splitForLocales } from "../../../utils-pure.js";
2
+ import { preNormalizeEntry } from "../urlset/normalise.js";
3
+ export function resolveSitemapEntries(sitemap, urls, runtimeConfig, resolvers, baseURL) {
4
+ const {
5
+ autoI18n,
6
+ isI18nMapped
7
+ } = runtimeConfig;
8
+ const hasFilters = !!sitemap.include?.length || !!sitemap.exclude?.length;
9
+ const filterPath = hasFilters ? createPathFilter({
10
+ include: sitemap.include,
11
+ exclude: sitemap.exclude
12
+ }, baseURL || "/") : void 0;
13
+ const _urls = [];
14
+ for (const _e of urls) {
15
+ const e = preNormalizeEntry(_e, resolvers);
16
+ if (e.loc && (!filterPath || filterPath(e.loc, e._path?.pathname)))
17
+ _urls.push(e);
18
+ }
19
+ const withoutPrefixPaths = {};
20
+ if (autoI18n && autoI18n.strategy !== "no_prefix") {
21
+ const localeCodes = new Set(autoI18n.locales.map((l) => l.code));
22
+ const localeByCode = new Map(autoI18n.locales.map((l) => [l.code, l]));
23
+ const defaultLocale = autoI18n.defaultLocale;
24
+ const hasDifferentDomains = !!autoI18n.differentDomains;
25
+ const validI18nUrlsForTransform = [];
26
+ for (let i = 0; i < _urls.length; i++) {
27
+ const _e = _urls[i];
28
+ if (_e._abs)
29
+ continue;
30
+ const split = splitForLocales(_e._relativeLoc, localeCodes);
31
+ let localeCode = split[0];
32
+ const pathWithoutPrefix = split[1];
33
+ if (!localeCode)
34
+ localeCode = defaultLocale;
35
+ const e = _e;
36
+ e._pathWithoutPrefix = pathWithoutPrefix;
37
+ const locale = localeByCode.get(localeCode);
38
+ if (!locale)
39
+ continue;
40
+ e._locale = locale;
41
+ e._index = i;
42
+ e._key = `${e._sitemap || ""}${e._path?.pathname || "/"}${e._path?.search || ""}`;
43
+ withoutPrefixPaths[pathWithoutPrefix] = withoutPrefixPaths[pathWithoutPrefix] || [];
44
+ if (!withoutPrefixPaths[pathWithoutPrefix].some((e2) => e2._locale.code === locale.code))
45
+ withoutPrefixPaths[pathWithoutPrefix].push(e);
46
+ validI18nUrlsForTransform.push(e);
47
+ }
48
+ for (const e of validI18nUrlsForTransform) {
49
+ if (!e._i18nTransform && !e.alternatives?.length) {
50
+ const alternatives = [];
51
+ for (const u of withoutPrefixPaths[e._pathWithoutPrefix] || []) {
52
+ if (u._locale.code === defaultLocale) {
53
+ alternatives.push({
54
+ href: u.loc,
55
+ hreflang: "x-default"
56
+ });
57
+ }
58
+ alternatives.push({
59
+ href: u.loc,
60
+ hreflang: u._locale._hreflang || defaultLocale
61
+ });
62
+ }
63
+ if (alternatives.length)
64
+ e.alternatives = alternatives;
65
+ } else if (e._i18nTransform) {
66
+ delete e._i18nTransform;
67
+ const routeEntries = resolveI18nRouteEntries(e._relativeLoc, autoI18n, (href) => !filterPath || filterPath(href));
68
+ if (hasDifferentDomains) {
69
+ e.alternatives = routeEntries[0]?.alternatives;
70
+ } else {
71
+ for (const { alternatives, locale: l, loc } of routeEntries) {
72
+ const _sitemap = isI18nMapped ? l._sitemap : void 0;
73
+ const { _index: _, ...rest } = e;
74
+ const newEntry = preNormalizeEntry({
75
+ _sitemap,
76
+ ...rest,
77
+ _key: `${_sitemap || ""}${loc || "/"}`,
78
+ _locale: l,
79
+ loc,
80
+ alternatives
81
+ }, resolvers);
82
+ if (e._locale.code === newEntry._locale.code) {
83
+ _urls[e._index] = newEntry;
84
+ e._index = void 0;
85
+ } else {
86
+ _urls.push(newEntry);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ if (isI18nMapped) {
92
+ e._sitemap = e._sitemap || e._locale._sitemap;
93
+ e._key = `${e._sitemap || ""}${e.loc || "/"}${e._path?.search || ""}`;
94
+ }
95
+ if (e._index)
96
+ _urls[e._index] = e;
97
+ }
98
+ }
99
+ return _urls;
100
+ }
@@ -1,10 +1,4 @@
1
- import type { NitroApp } from 'nitropack/types';
2
- import type { ModuleRuntimeConfig, NitroUrlResolvers, SitemapIndexEntry } from '../../../types.js';
3
- export declare function buildSitemapIndex(resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<{
4
- entries: SitemapIndexEntry[];
5
- failedSources: Array<{
6
- url: string;
7
- error: string;
8
- }>;
9
- }>;
1
+ import type { ModuleRuntimeConfig, NitroUrlResolvers } from '../../../types.js';
2
+ type NitroApp = ReturnType<typeof import('#nuxtseo/nitro').useNitroApp>;
3
+ export declare function buildSitemapIndex(resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<any>;
10
4
  export { urlsToIndexXml, urlsToIndexXmlStream } from './index-xml.js';
@@ -1,6 +1,6 @@
1
- import { getHeader } from "h3";
2
- import { defineCachedFunction } from "nitropack/runtime";
3
1
  import { joinURL } from "ufo";
2
+ import { getHeader } from "#nuxtseo/h3";
3
+ import { defineCachedFunction } from "#nuxtseo/nitro";
4
4
  import staticConfig from "#sitemap-virtual/static-config.mjs";
5
5
  import { normaliseDate } from "../urlset/normalise.js";
6
6
  import { getResolvedSitemapUrls } from "./sitemap.js";
@@ -1,12 +1,5 @@
1
- import type { H3Event } from 'h3';
2
- import type { NitroApp } from 'nitropack/types';
3
- import type { AutoI18nConfig, ModuleRuntimeConfig, NitroUrlResolvers, ResolvedSitemapUrl, SitemapDefinition, SitemapUrlInput } from '../../../types.js';
4
- export interface NormalizedI18n extends ResolvedSitemapUrl {
5
- _pathWithoutPrefix: string;
6
- _locale: AutoI18nConfig['locales'][number];
7
- _index?: number;
8
- }
9
- export declare function resolveSitemapEntries(sitemap: SitemapDefinition, urls: SitemapUrlInput[], runtimeConfig: Pick<ModuleRuntimeConfig, 'autoI18n' | 'isI18nMapped'>, resolvers?: NitroUrlResolvers, baseURL?: string): ResolvedSitemapUrl[];
1
+ import type { ModuleRuntimeConfig, NitroUrlResolvers, ResolvedSitemapUrl, SitemapDefinition } from '../../../types.js';
2
+ type NitroApp = ReturnType<typeof import('#nuxtseo/nitro').useNitroApp>;
10
3
  export interface ResolvedSitemapUrlsResult {
11
4
  urls: ResolvedSitemapUrl[];
12
5
  failedSources: Array<{
@@ -15,7 +8,7 @@ export interface ResolvedSitemapUrlsResult {
15
8
  }>;
16
9
  }
17
10
  export declare function buildResolvedSitemapUrls(effectiveSitemap: SitemapDefinition, matchName: string, isChunked: boolean, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
18
- export declare const buildResolvedSitemapUrlsCached: (_event: H3Event<import("h3").EventHandlerRequest>, effectiveSitemap: SitemapDefinition, matchName: string, isChunked: boolean, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp | undefined) => Promise<ResolvedSitemapUrlsResult>;
11
+ export declare const buildResolvedSitemapUrlsCached: any;
19
12
  export declare function getResolvedSitemapUrls(effectiveSitemap: SitemapDefinition, matchName: string, isChunked: boolean, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
20
13
  export declare function buildSitemapUrls(sitemap: SitemapDefinition, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
21
14
  export { urlsToXml, urlsToXmlStream } from './xml.js';
@@ -1,172 +1,14 @@
1
- import { getHeader } from "h3";
2
- import { defineCachedFunction, useRuntimeConfig } from "nitropack/runtime";
3
1
  import { resolveSitePath } from "nuxt-site-config/urls";
4
- import { joinURL, withHttps } from "ufo";
2
+ import { withHttps } from "ufo";
3
+ import { getHeader } from "#nuxtseo/h3";
4
+ import { defineCachedFunction, useRuntimeConfig } from "#nuxtseo/nitro";
5
5
  import staticConfig from "#sitemap-virtual/static-config.mjs";
6
- import { applyDynamicParams, createPathFilter, findPageMapping, logger, resolveI18nSitemapLocaleKey, splitForLocales } from "../../../utils-pure.js";
7
- import { preNormalizeEntry } from "../urlset/normalise.js";
6
+ import { logger, resolveI18nSitemapLocaleKey } from "../../../utils-pure.js";
8
7
  import { sortInPlace } from "../urlset/sort.js";
9
8
  import { childSitemapSources, globalSitemapSources, resolveSitemapSources } from "../urlset/sources.js";
10
9
  import { parseChunkInfo, sliceUrlsForChunk } from "../utils/chunk.js";
10
+ import { resolveSitemapEntries } from "./entries.js";
11
11
  const SERVER_CACHE_MAX_AGE = staticConfig.cacheMaxAgeSeconds || 60 * 10;
12
- export function resolveSitemapEntries(sitemap, urls, runtimeConfig, resolvers, baseURL) {
13
- const {
14
- autoI18n,
15
- isI18nMapped
16
- } = runtimeConfig;
17
- const hasFilters = !!sitemap.include?.length || !!sitemap.exclude?.length;
18
- const filterPath = hasFilters ? createPathFilter({
19
- include: sitemap.include,
20
- exclude: sitemap.exclude
21
- }, baseURL || "/") : void 0;
22
- const _urls = [];
23
- for (const _e of urls) {
24
- const e = preNormalizeEntry(_e, resolvers);
25
- if (e.loc && (!filterPath || filterPath(e.loc, e._path?.pathname)))
26
- _urls.push(e);
27
- }
28
- const withoutPrefixPaths = {};
29
- if (autoI18n && autoI18n.strategy !== "no_prefix") {
30
- const localeCodes = new Set(autoI18n.locales.map((l) => l.code));
31
- const localeByCode = new Map(autoI18n.locales.map((l) => [l.code, l]));
32
- const isPrefixStrategy = autoI18n.strategy === "prefix";
33
- const isPrefixExceptOrAndDefault = autoI18n.strategy === "prefix_and_default" || autoI18n.strategy === "prefix_except_default";
34
- const xDefaultAndLocales = [{ code: "x-default", _hreflang: "x-default" }, ...autoI18n.locales];
35
- const defaultLocale = autoI18n.defaultLocale;
36
- const hasPages = !!autoI18n.pages;
37
- const sortedPageKeys = hasPages ? Object.keys(autoI18n.pages).sort((a, b) => b.length - a.length) : void 0;
38
- const hasDifferentDomains = !!autoI18n.differentDomains;
39
- const validI18nUrlsForTransform = [];
40
- for (let i = 0; i < _urls.length; i++) {
41
- const _e = _urls[i];
42
- if (_e._abs)
43
- continue;
44
- const split = splitForLocales(_e._relativeLoc, localeCodes);
45
- let localeCode = split[0];
46
- const pathWithoutPrefix = split[1];
47
- if (!localeCode)
48
- localeCode = defaultLocale;
49
- const e = _e;
50
- e._pathWithoutPrefix = pathWithoutPrefix;
51
- const locale = localeByCode.get(localeCode);
52
- if (!locale)
53
- continue;
54
- e._locale = locale;
55
- e._index = i;
56
- e._key = `${e._sitemap || ""}${e._path?.pathname || "/"}${e._path?.search || ""}`;
57
- withoutPrefixPaths[pathWithoutPrefix] = withoutPrefixPaths[pathWithoutPrefix] || [];
58
- if (!withoutPrefixPaths[pathWithoutPrefix].some((e2) => e2._locale.code === locale.code))
59
- withoutPrefixPaths[pathWithoutPrefix].push(e);
60
- validI18nUrlsForTransform.push(e);
61
- }
62
- for (const e of validI18nUrlsForTransform) {
63
- if (!e._i18nTransform && !e.alternatives?.length) {
64
- const alternatives = [];
65
- for (const u of withoutPrefixPaths[e._pathWithoutPrefix] || []) {
66
- if (u._locale.code === defaultLocale) {
67
- alternatives.push({
68
- href: u.loc,
69
- hreflang: "x-default"
70
- });
71
- }
72
- alternatives.push({
73
- href: u.loc,
74
- hreflang: u._locale._hreflang || defaultLocale
75
- });
76
- }
77
- if (alternatives.length)
78
- e.alternatives = alternatives;
79
- } else if (e._i18nTransform) {
80
- delete e._i18nTransform;
81
- if (hasDifferentDomains) {
82
- const defLocale = localeByCode.get(defaultLocale);
83
- e.alternatives = [
84
- {
85
- ...defLocale,
86
- code: "x-default"
87
- },
88
- ...autoI18n.locales.filter((l) => !!l.domain)
89
- ].map((locale) => {
90
- return {
91
- hreflang: locale._hreflang,
92
- href: joinURL(withHttps(locale.domain), e._pathWithoutPrefix)
93
- };
94
- });
95
- } else {
96
- const pageMatch = hasPages ? findPageMapping(e._pathWithoutPrefix, autoI18n.pages, sortedPageKeys) : null;
97
- const pathSearch = e._path?.search || "";
98
- const pathWithoutPrefix = e._pathWithoutPrefix;
99
- for (const l of autoI18n.locales) {
100
- let loc = pathWithoutPrefix;
101
- if (pageMatch && pageMatch.mappings[l.code] !== void 0) {
102
- const customPath = pageMatch.mappings[l.code];
103
- if (customPath === false)
104
- continue;
105
- if (typeof customPath === "string") {
106
- loc = customPath[0] === "/" ? customPath : `/${customPath}`;
107
- loc = applyDynamicParams(loc, pageMatch.paramSegments);
108
- if (isPrefixStrategy || isPrefixExceptOrAndDefault && l.code !== defaultLocale)
109
- loc = joinURL(`/${l.code}`, loc);
110
- }
111
- } else if (!hasDifferentDomains && !(isPrefixExceptOrAndDefault && l.code === defaultLocale)) {
112
- loc = joinURL(`/${l.code}`, pathWithoutPrefix);
113
- }
114
- const _sitemap = isI18nMapped ? l._sitemap : void 0;
115
- const alternatives = [];
116
- for (const locale of xDefaultAndLocales) {
117
- const code = locale.code === "x-default" ? defaultLocale : locale.code;
118
- const isDefault = locale.code === "x-default" || locale.code === defaultLocale;
119
- let href = pathWithoutPrefix;
120
- if (pageMatch && pageMatch.mappings[code] !== void 0) {
121
- const customPath = pageMatch.mappings[code];
122
- if (customPath === false)
123
- continue;
124
- if (typeof customPath === "string") {
125
- href = customPath[0] === "/" ? customPath : `/${customPath}`;
126
- href = applyDynamicParams(href, pageMatch.paramSegments);
127
- if (isPrefixStrategy || isPrefixExceptOrAndDefault && !isDefault)
128
- href = joinURL("/", code, href);
129
- }
130
- } else if (isPrefixStrategy) {
131
- href = joinURL("/", code, pathWithoutPrefix);
132
- } else if (isPrefixExceptOrAndDefault && !isDefault) {
133
- href = joinURL("/", code, pathWithoutPrefix);
134
- }
135
- if (filterPath && !filterPath(href))
136
- continue;
137
- alternatives.push({
138
- hreflang: locale._hreflang,
139
- href
140
- });
141
- }
142
- const { _index: _, ...rest } = e;
143
- const newEntry = preNormalizeEntry({
144
- _sitemap,
145
- ...rest,
146
- _key: `${_sitemap || ""}${loc || "/"}${pathSearch}`,
147
- _locale: l,
148
- loc,
149
- alternatives
150
- }, resolvers);
151
- if (e._locale.code === newEntry._locale.code) {
152
- _urls[e._index] = newEntry;
153
- e._index = void 0;
154
- } else {
155
- _urls.push(newEntry);
156
- }
157
- }
158
- }
159
- }
160
- if (isI18nMapped) {
161
- e._sitemap = e._sitemap || e._locale._sitemap;
162
- e._key = `${e._sitemap || ""}${e.loc || "/"}${e._path?.search || ""}`;
163
- }
164
- if (e._index)
165
- _urls[e._index] = e;
166
- }
167
- }
168
- return _urls;
169
- }
170
12
  export async function buildResolvedSitemapUrls(effectiveSitemap, matchName, isChunked, resolvers, runtimeConfig, nitro) {
171
13
  const { sitemaps, autoI18n, isI18nMapped, isMultiSitemap, sortEntries } = runtimeConfig;
172
14
  let sourcesInput = effectiveSitemap.includeAppSources ? [...await globalSitemapSources(), ...await childSitemapSources(effectiveSitemap)] : await childSitemapSources(effectiveSitemap);
@@ -1,4 +1,4 @@
1
- import type { H3Event } from 'h3';
2
- export declare function sitemapXmlEventHandler(e: H3Event): Promise<string | void | ReadableStream<Uint8Array<ArrayBufferLike>>>;
1
+ import type { H3Event } from '#nuxtseo/h3';
2
+ export declare function sitemapXmlEventHandler(e: H3Event): Promise<any>;
3
3
  export declare function sitemapIndexXmlEventHandler(e: H3Event): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>;
4
4
  export declare function sitemapChildXmlEventHandler(e: H3Event): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>> | undefined>;
@@ -1,6 +1,6 @@
1
- import { appendHeader, createError, getRequestURL, getRouterParam, sendRedirect } from "h3";
2
- import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
3
1
  import { joinURL, withBase, withLeadingSlash, withoutLeadingSlash, withoutTrailingSlash } from "ufo";
2
+ import { appendHeader, createError, getRequestURL, getRouterParam, sendRedirect } from "#nuxtseo/h3";
3
+ import { useNitroApp, useRuntimeConfig } from "#nuxtseo/nitro";
4
4
  import { useSitemapRuntimeConfig } from "../utils.js";
5
5
  import { urlsToIndexXml, urlsToIndexXmlStream } from "./builder/index-xml.js";
6
6
  import { buildSitemapIndex } from "./builder/sitemap-index.js";
@@ -1,7 +1,9 @@
1
- import type { H3Event } from 'h3';
2
- import type { NitroApp } from 'nitropack/types';
1
+ import type { H3Event } from '#nuxtseo/h3';
3
2
  import type { ModuleRuntimeConfig, NitroUrlResolvers, SitemapDefinition } from '../../types.js';
3
+ import { useNitroApp } from '#nuxtseo/nitro';
4
+ type NitroApp = ReturnType<typeof useNitroApp>;
4
5
  export declare function useNitroUrlResolvers(e: H3Event): NitroUrlResolvers;
5
6
  export declare function renderSitemapOutput(nitro: NitroApp, event: H3Event, sitemapName: string, renderString: () => string, renderStream: () => ReadableStream<Uint8Array>, shouldStream: boolean, debug: boolean): Promise<string | ReadableStream<Uint8Array>>;
6
7
  export declare function setSitemapResponseHeaders(event: H3Event, runtimeConfig: ModuleRuntimeConfig): void;
7
8
  export declare function createSitemap(event: H3Event, definition: SitemapDefinition, runtimeConfig: ModuleRuntimeConfig): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>;
9
+ export {};
@@ -1,9 +1,9 @@
1
1
  import { defu } from "defu";
2
- import { createError, getHeader, getQuery, setHeader } from "h3";
3
- import { defineCachedFunction, useNitroApp, useRuntimeConfig } from "nitropack/runtime";
4
2
  import { fixSlashes } from "nuxt-site-config/urls";
5
3
  import { createNitroRouteRuleMatcher } from "nuxtseo-shared/server";
6
4
  import { getPathRobotConfig } from "#internal/nuxt-robots/getPathRobotConfig";
5
+ import { createError, getHeader, getQuery, setHeader } from "#nuxtseo/h3";
6
+ import { defineCachedFunction, useNitroApp, useRuntimeConfig } from "#nuxtseo/nitro";
7
7
  import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
8
8
  import { createSitePathResolver } from "#site-config/server/composables/utils";
9
9
  import staticConfig from "#sitemap-virtual/static-config.mjs";
@@ -1,4 +1,4 @@
1
- import type { H3Event } from 'h3';
1
+ import type { H3Event } from '#nuxtseo/h3';
2
2
  import type { ModuleRuntimeConfig, SitemapSourceBase, SitemapSourceInput, SitemapSourceResolved } from '../../../types.js';
3
3
  export declare function normalizeSourceInput(source: SitemapSourceInput): SitemapSourceBase | SitemapSourceResolved;
4
4
  export declare function fetchDataSource(input: SitemapSourceBase | SitemapSourceResolved, event?: H3Event): Promise<SitemapSourceResolved>;
@@ -1,7 +1,9 @@
1
1
  import { defu } from "defu";
2
- import { getRequestHost } from "h3";
2
+ import { $fetch } from "ofetch";
3
3
  import { collectSitemap } from "sitemapd/parse";
4
4
  import { parseURL } from "ufo";
5
+ import { getRequestHost } from "#nuxtseo/h3";
6
+ import { fetchWithEvent } from "#nuxtseo/nitro";
5
7
  import { logger } from "../../../utils-pure.js";
6
8
  const changeFrequencies = /* @__PURE__ */ new Set([
7
9
  "always",
@@ -50,7 +52,7 @@ async function tryFetchWithFallback(url, options, event) {
50
52
  // Strategy 1: Use globalThis.$fetch (original approach)
51
53
  () => globalThis.$fetch(url, options),
52
54
  // Strategy 2: If event is available, try using event context even for external URLs
53
- event ? () => event.$fetch(url, options) : null,
55
+ event ? () => fetchWithEvent(event, url, options) : null,
54
56
  // Strategy 3: Use native fetch as last resort
55
57
  () => $fetch(url, options)
56
58
  ].filter(Boolean);
@@ -65,8 +67,7 @@ async function tryFetchWithFallback(url, options, event) {
65
67
  }
66
68
  throw lastError;
67
69
  }
68
- const fetchContainer = url.startsWith("/") && event ? event : globalThis;
69
- return await fetchContainer.$fetch(url, options);
70
+ return event ? await fetchWithEvent(event, url, options) : await globalThis.$fetch(url, options);
70
71
  }
71
72
  export async function fetchDataSource(input, event) {
72
73
  const context = typeof input.context === "string" ? { name: input.context } : input.context || { name: "fetch" };
@@ -1,4 +1,4 @@
1
- import type { H3Event } from 'h3';
1
+ import type { H3Event } from '#nuxtseo/h3';
2
2
  import type { ModuleRuntimeConfig } from '../types.js';
3
3
  export * from '../utils-pure.js';
4
4
  export declare function useSitemapRuntimeConfig(e?: H3Event): ModuleRuntimeConfig;
@@ -1,4 +1,4 @@
1
- import { useRuntimeConfig } from "nitropack/runtime";
1
+ import { useRuntimeConfig } from "#nuxtseo/nitro";
2
2
  import staticConfig from "#sitemap-virtual/static-config.mjs";
3
3
  import { normalizeRuntimeFilters } from "../utils-pure.js";
4
4
  export * from "../utils-pure.js";
@@ -376,25 +376,25 @@ export interface SitemapDefinition {
376
376
  */
377
377
  _chunkCount?: number;
378
378
  }
379
- interface NitroBaseHook {
380
- event: H3Event;
379
+ interface NitroBaseHook<Event = H3Event> {
380
+ event: Event;
381
381
  }
382
- export interface SitemapIndexRenderCtx extends NitroBaseHook {
382
+ export interface SitemapIndexRenderCtx<Event = H3Event> extends NitroBaseHook<Event> {
383
383
  sitemaps: SitemapIndexEntry[];
384
384
  }
385
- export interface SitemapRenderCtx extends NitroBaseHook {
385
+ export interface SitemapRenderCtx<Event = H3Event> extends NitroBaseHook<Event> {
386
386
  sitemapName: string;
387
387
  urls: ResolvedSitemapUrl[];
388
388
  }
389
- export interface SitemapInputCtx extends NitroBaseHook {
389
+ export interface SitemapInputCtx<Event = H3Event> extends NitroBaseHook<Event> {
390
390
  sitemapName: string;
391
391
  urls: SitemapUrlInput[];
392
392
  }
393
- export interface SitemapOutputHookCtx extends NitroBaseHook {
393
+ export interface SitemapOutputHookCtx<Event = H3Event> extends NitroBaseHook<Event> {
394
394
  sitemapName: string;
395
395
  sitemap: string;
396
396
  }
397
- export interface SitemapSourcesHookCtx extends NitroBaseHook {
397
+ export interface SitemapSourcesHookCtx<Event = H3Event> extends NitroBaseHook<Event> {
398
398
  sitemapName: string;
399
399
  sources: SitemapSourceInput[];
400
400
  }
@@ -1,9 +1,15 @@
1
- import type { FilterInput } from './types.js';
1
+ import type { AlternativeEntry, AutoI18nConfig, FilterInput } from './types.js';
2
2
  export { createFilter, type CreateFilterOptions } from 'nuxtseo-shared/utils';
3
3
  export declare const logger: import("consola").ConsolaInstance;
4
4
  export declare function xmlEscape(value: string | number | boolean | Date): string;
5
5
  export declare function mergeOnKey<T, K extends keyof T>(arr: T[], key: K, onMerge?: (key: T[K]) => void): T[];
6
6
  export declare function splitForLocales(path: string, locales: readonly string[] | Set<string>): [string | null, string];
7
+ export interface ResolvedI18nRouteEntry {
8
+ locale: AutoI18nConfig['locales'][number];
9
+ loc: string;
10
+ alternatives: AlternativeEntry[];
11
+ }
12
+ export declare function resolveI18nRouteEntries(route: string, i18n: AutoI18nConfig, includeHref?: (href: string) => boolean): ResolvedI18nRouteEntry[];
7
13
  /**
8
14
  * Resolve which locale a multi-sitemap name belongs to.
9
15
  *
@@ -22,9 +28,3 @@ export declare function createPathFilter(options?: {
22
28
  include?: (FilterInput | string | RegExp)[];
23
29
  exclude?: (FilterInput | string | RegExp)[];
24
30
  }, baseURL?: string): (loc: string, pathname?: string) => boolean;
25
- export interface PageMatch {
26
- mappings: Record<string, string | false>;
27
- paramSegments: string[];
28
- }
29
- export declare function findPageMapping(pathWithoutPrefix: string, pages: Record<string, Record<string, string | false>>, sortedKeys?: string[]): PageMatch | null;
30
- export declare function applyDynamicParams(customPath: string, paramSegments: string[]): string;
@@ -1,6 +1,7 @@
1
1
  import { createDefu } from "defu";
2
+ import { computeLocaleAlternates, resolveLocaleFromRoute } from "nuxtseo-shared/i18n-runtime";
2
3
  import { createFilter, createModuleLogger } from "nuxtseo-shared/utils";
3
- import { parseURL, withoutBase } from "ufo";
4
+ import { joinURL, parseURL, withHttps, withLeadingSlash, withoutBase } from "ufo";
4
5
  export { createFilter } from "nuxtseo-shared/utils";
5
6
  export const logger = createModuleLogger("@nuxt/sitemap");
6
7
  const XML_ENTITIES = {
@@ -51,6 +52,47 @@ export function splitForLocales(path, locales) {
51
52
  }
52
53
  return [null, path];
53
54
  }
55
+ function toRuntimeI18nConfig(i18n) {
56
+ return {
57
+ ...i18n,
58
+ // Sitemap transforms keep the unprefixed default URL alongside Nuxt's prefixed route.
59
+ strategy: i18n.strategy === "prefix_and_default" ? "prefix_except_default" : i18n.strategy,
60
+ pages: i18n.pages && Object.fromEntries(
61
+ Object.entries(i18n.pages).map(([pageName, pageLocales]) => [
62
+ pageName,
63
+ Object.fromEntries(i18n.locales.map((locale) => {
64
+ const configuredPath = pageLocales[locale.code];
65
+ return [locale.code, configuredPath === void 0 ? withLeadingSlash(pageName) : configuredPath];
66
+ }))
67
+ ])
68
+ ),
69
+ locales: i18n.locales.map((locale) => ({
70
+ ...locale,
71
+ hreflang: locale._hreflang
72
+ }))
73
+ };
74
+ }
75
+ function localeAlternateHref(alternate) {
76
+ return alternate.domain ? joinURL(withHttps(alternate.domain), alternate.path) : alternate.path;
77
+ }
78
+ export function resolveI18nRouteEntries(route, i18n, includeHref = () => true) {
79
+ const runtimeConfig = toRuntimeI18nConfig(i18n);
80
+ const currentLocale = resolveLocaleFromRoute(route, runtimeConfig).locale;
81
+ const alternates = computeLocaleAlternates(route, runtimeConfig, { locale: currentLocale });
82
+ const localizedAlternates = alternates.map((alternate) => ({
83
+ alternate,
84
+ href: localeAlternateHref(alternate)
85
+ }));
86
+ const defaultHref = localizedAlternates.find(({ alternate }) => alternate.code === i18n.defaultLocale)?.href;
87
+ const sitemapAlternatives = [
88
+ ...defaultHref && includeHref(defaultHref) ? [{ hreflang: "x-default", href: defaultHref }] : [],
89
+ ...localizedAlternates.filter(({ href }) => includeHref(href)).map(({ alternate, href }) => ({ hreflang: alternate.hreflang, href }))
90
+ ];
91
+ return localizedAlternates.flatMap(({ alternate, href }) => {
92
+ const locale = i18n.locales.find((locale2) => locale2.code === alternate.code);
93
+ return locale ? [{ locale, loc: href, alternatives: sitemapAlternatives }] : [];
94
+ });
95
+ }
54
96
  export function resolveI18nSitemapLocaleKey(sitemapName, localeSitemapKeys) {
55
97
  let best = null;
56
98
  for (const key of localeSitemapKeys) {
@@ -89,26 +131,6 @@ export function createPathFilter(options = {}, baseURL) {
89
131
  }
90
132
  if (hasBase)
91
133
  path = withoutBase(path, baseURL);
92
- return urlFilter(path);
134
+ return urlFilter(withLeadingSlash(path));
93
135
  };
94
136
  }
95
- export function findPageMapping(pathWithoutPrefix, pages, sortedKeys) {
96
- const stripped = pathWithoutPrefix[0] === "/" ? pathWithoutPrefix.slice(1) : pathWithoutPrefix;
97
- const pageKey = stripped.endsWith("/index") ? stripped.slice(0, -6) || "index" : stripped || "index";
98
- if (pages[pageKey])
99
- return { mappings: pages[pageKey], paramSegments: [] };
100
- const keys = sortedKeys || Object.keys(pages).sort((a, b) => b.length - a.length);
101
- for (const key of keys) {
102
- if (pageKey.startsWith(`${key}/`)) {
103
- const paramPath = pageKey.slice(key.length + 1);
104
- return { mappings: pages[key], paramSegments: paramPath.split("/") };
105
- }
106
- }
107
- return null;
108
- }
109
- export function applyDynamicParams(customPath, paramSegments) {
110
- if (!paramSegments.length)
111
- return customPath;
112
- let i = 0;
113
- return customPath.replace(/\[[^\]]+\]/g, () => paramSegments[i++] || "");
114
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/sitemap",
3
3
  "type": "module",
4
- "version": "8.3.2",
4
+ "version": "8.3.4",
5
5
  "description": "Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -55,45 +55,45 @@
55
55
  }
56
56
  },
57
57
  "dependencies": {
58
- "@nuxt/kit": "^4.5.1",
58
+ "@nuxt/kit": "^4.5.2",
59
59
  "consola": "^3.4.2",
60
60
  "defu": "^6.1.7",
61
- "nuxt-site-config": "^4.1.2",
62
- "nuxtseo-shared": "^5.3.6",
61
+ "nuxt-site-config": "^4.2.0",
62
+ "nuxtseo-shared": "^5.3.11",
63
63
  "ofetch": "^1.5.1",
64
64
  "pathe": "^2.0.3",
65
65
  "pkg-types": "^2.3.1",
66
66
  "radix3": "^1.1.2",
67
67
  "ufo": "^1.6.4",
68
68
  "ultrahtml": "^1.7.0",
69
- "sitemapd": "^0.2.0"
69
+ "sitemapd": "^0.2.1"
70
70
  },
71
71
  "devDependencies": {
72
- "@antfu/eslint-config": "^9.2.0",
72
+ "@antfu/eslint-config": "^9.3.0",
73
73
  "@arethetypeswrong/cli": "^0.18.5",
74
74
  "@nuxt/content": "^3.15.2",
75
75
  "@nuxt/devtools-kit": "4.0.0-alpha.9",
76
76
  "@nuxt/module-builder": "^1.0.3",
77
77
  "@nuxt/test-utils": "^4.1.0",
78
78
  "@nuxt/ui": "^4.10.0",
79
- "@nuxtjs/i18n": "^10.5.0",
80
- "@nuxtjs/robots": "^6.1.3",
79
+ "@nuxtjs/i18n": "^10.6.0",
80
+ "@nuxtjs/robots": "^6.1.4",
81
81
  "@vue/test-utils": "^2.4.11",
82
- "better-sqlite3": "^13.0.1",
83
- "bumpp": "^12.1.1",
84
- "eslint": "^10.8.0",
82
+ "better-sqlite3": "^13.0.3",
83
+ "bumpp": "^12.2.0",
84
+ "eslint": "^10.8.1",
85
85
  "eslint-plugin-harlanzw": "^0.17.1",
86
- "happy-dom": "^20.11.1",
87
- "nuxt": "^4.5.1",
88
- "nuxt-i18n-micro": "^3.21.4",
89
- "nuxtseo-layer-devtools": "^5.3.6",
86
+ "happy-dom": "^20.11.2",
87
+ "nuxt": "^4.5.2",
88
+ "nuxt-i18n-micro": "^3.28.0",
89
+ "nuxtseo-layer-devtools": "^5.3.11",
90
90
  "std-env": "^4.2.0",
91
91
  "typescript": "6.0.3",
92
92
  "unbuild": "^3.6.1",
93
93
  "vitest": "^4.1.10",
94
- "vue-tsc": "^3.3.8",
94
+ "vue-tsc": "^3.3.9",
95
95
  "zod": "^4.4.3",
96
- "@nuxtjs/sitemap": "8.3.2"
96
+ "@nuxtjs/sitemap": "8.3.4"
97
97
  },
98
98
  "scripts": {
99
99
  "lint": "eslint .",
@@ -106,8 +106,9 @@
106
106
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground && pnpm run client:build",
107
107
  "release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
108
108
  "release:sitemapd": "pnpm --filter sitemapd release",
109
- "test": "pnpm --filter sitemapd test && vitest run && pnpm run test:attw",
109
+ "test": "pnpm --filter sitemapd test && vitest run && pnpm run test:attw && pnpm run test:nuxt5",
110
110
  "test:unit": "vitest --project=unit",
111
+ "test:nuxt5": "pnpm pack --out test/fixtures/nuxt5/module.tgz && pnpm install --dir test/fixtures/nuxt5 --no-frozen-lockfile --update-checksums && pnpm --dir test/fixtures/nuxt5 test",
111
112
  "test:attw": "attw --pack && pnpm --filter sitemapd test:attw",
112
113
  "typecheck": "pnpm --filter sitemapd typecheck && nuxt typecheck"
113
114
  }