@nuxtjs/sitemap 7.4.11 → 7.5.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.
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/BZzBMR0a.js +155 -0
- package/dist/client/_nuxt/{CjT5ejtq.js → BcLzIRTJ.js} +1 -1
- package/dist/client/_nuxt/{DBmpb9dG.js → CQIolwG-.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/c9c08595-dc8d-4073-931c-6ba959692bc1.json +1 -0
- package/dist/client/_nuxt/error-404.DKXSOdpM.css +1 -0
- package/dist/client/_nuxt/error-500.rUXo3Kq4.css +1 -0
- package/dist/client/index.html +1 -1
- package/dist/client/sitemap.xml +1 -1
- package/dist/module.d.mts +14 -2
- package/dist/module.d.ts +14 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +83 -31
- package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.d.ts +2 -0
- package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.js +8 -0
- package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.d.ts +2 -0
- package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.js +8 -0
- package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.d.ts +2 -0
- package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.js +8 -0
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.js +3 -50
- package/dist/runtime/server/routes/sitemap.xml.js +3 -13
- package/dist/runtime/server/routes/sitemap_index.xml.js +3 -42
- package/dist/runtime/server/sitemap/builder/sitemap.js +16 -13
- package/dist/runtime/server/sitemap/builder/xml.js +1 -1
- package/dist/runtime/server/sitemap/event-handlers.d.ts +4 -0
- package/dist/runtime/server/sitemap/event-handlers.js +77 -0
- package/dist/runtime/server/sitemap/urlset/normalise.js +4 -2
- package/dist/runtime/server/sitemap/urlset/sources.d.ts +3 -2
- package/dist/runtime/server/sitemap/urlset/sources.js +16 -6
- package/dist/runtime/types.d.ts +25 -1
- package/dist/runtime/utils-pure.d.ts +6 -0
- package/dist/runtime/utils-pure.js +20 -0
- package/dist/types.d.mts +7 -1
- package/package.json +8 -7
- package/dist/client/_nuxt/FE81ed4p.js +0 -155
- package/dist/client/_nuxt/builds/meta/ef370d03-581a-4487-a7bd-237af16aab04.json +0 -1
- package/dist/client/_nuxt/error-404.DC9fsYfS.css +0 -1
- package/dist/client/_nuxt/error-500.DPVweS-0.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as s,u as a,c as i,o as u,a as t,t as n,b as c,w as l,d,e as f}from"./
|
|
1
|
+
import{_ as s,u as a,c as i,o as u,a as t,t as n,b as c,w as l,d,e as f}from"./BZzBMR0a.js";const p={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},m={class:"max-w-520px text-center"},h=["textContent"],b=["textContent"],g=["textContent"],x={class:"flex items-center justify-center w-full"},y={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Page not found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(e){const r=e;return a({title:`${r.statusCode} - ${r.statusMessage} | ${r.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)}).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(k,w)=>{const o=f;return u(),i("div",p,[t("div",m,[t("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:n(e.statusCode)},null,8,h),t("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:n(e.statusMessage)},null,8,b),t("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:n(e.description)},null,8,g),t("div",x,[c(o,{to:"/",class:"font-medium hover:text-[#00DC82] text-sm underline underline-offset-3"},{default:l(()=>[d(n(e.backHome),1)]),_:1})])])])}}},C=s(y,[["__scopeId","data-v-f52c008b"]]);export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as o,u as s,c as a,o as i,a as t,t as r}from"./
|
|
1
|
+
import{_ as o,u as s,c as a,o as i,a as t,t as r}from"./BZzBMR0a.js";const u={class:"antialiased bg-white dark:bg-[#020420] dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-[#020420] tracking-wide"},l={class:"max-w-520px text-center"},c=["textContent"],d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Internal server error"},description:{type:String,default:"This page is temporarily unavailable."},refresh:{type:String,default:"Refresh this page"}},setup(e){const n=e;return s({title:`${n.statusCode} - ${n.statusMessage} | ${n.appName}`,script:[{innerHTML:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver(e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)}).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{innerHTML:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1,h2{font-size:inherit;font-weight:inherit}h1,h2,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,h)=>(i(),a("div",u,[t("div",l,[t("h1",{class:"font-semibold leading-none mb-4 sm:text-[110px] tabular-nums text-[80px]",textContent:r(e.statusCode)},null,8,c),t("h2",{class:"font-semibold mb-2 sm:text-3xl text-2xl",textContent:r(e.statusMessage)},null,8,d),t("p",{class:"mb-4 px-2 text-[#64748B] text-md",textContent:r(e.description)},null,8,p)])]))}},b=o(f,[["__scopeId","data-v-de2a56d3"]]);export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"c9c08595-dc8d-4073-931c-6ba959692bc1","timestamp":1767659680634}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"c9c08595-dc8d-4073-931c-6ba959692bc1","timestamp":1767659680634,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.grid[data-v-f52c008b]{display:grid}.mb-2[data-v-f52c008b]{margin-bottom:.5rem}.mb-4[data-v-f52c008b]{margin-bottom:1rem}.max-w-520px[data-v-f52c008b]{max-width:520px}.min-h-screen[data-v-f52c008b]{min-height:100vh}.w-full[data-v-f52c008b]{width:100%}.flex[data-v-f52c008b]{display:flex}.place-content-center[data-v-f52c008b]{place-content:center}.items-center[data-v-f52c008b]{align-items:center}.justify-center[data-v-f52c008b]{justify-content:center}.overflow-hidden[data-v-f52c008b]{overflow:hidden}.bg-white[data-v-f52c008b]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-f52c008b]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-f52c008b]{text-align:center}.text-\[80px\][data-v-f52c008b]{font-size:80px}.text-2xl[data-v-f52c008b]{font-size:1.5rem;line-height:2rem}.text-sm[data-v-f52c008b]{font-size:.875rem;line-height:1.25rem}.text-\[\#020420\][data-v-f52c008b]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-f52c008b]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.hover\:text-\[\#00DC82\][data-v-f52c008b]:hover{--un-text-opacity:1;color:rgb(0 220 130/var(--un-text-opacity))}.font-medium[data-v-f52c008b]{font-weight:500}.font-semibold[data-v-f52c008b]{font-weight:600}.leading-none[data-v-f52c008b]{line-height:1}.tracking-wide[data-v-f52c008b]{letter-spacing:.025em}.font-sans[data-v-f52c008b]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-f52c008b]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.underline[data-v-f52c008b]{text-decoration-line:underline}.underline-offset-3[data-v-f52c008b]{text-underline-offset:3px}.antialiased[data-v-f52c008b]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-f52c008b]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-f52c008b]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-f52c008b]{font-size:110px}.sm\:text-3xl[data-v-f52c008b]{font-size:1.875rem;line-height:2.25rem}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.grid[data-v-de2a56d3]{display:grid}.mb-2[data-v-de2a56d3]{margin-bottom:.5rem}.mb-4[data-v-de2a56d3]{margin-bottom:1rem}.max-w-520px[data-v-de2a56d3]{max-width:520px}.min-h-screen[data-v-de2a56d3]{min-height:100vh}.place-content-center[data-v-de2a56d3]{place-content:center}.overflow-hidden[data-v-de2a56d3]{overflow:hidden}.bg-white[data-v-de2a56d3]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-2[data-v-de2a56d3]{padding-left:.5rem;padding-right:.5rem}.text-center[data-v-de2a56d3]{text-align:center}.text-\[80px\][data-v-de2a56d3]{font-size:80px}.text-2xl[data-v-de2a56d3]{font-size:1.5rem;line-height:2rem}.text-\[\#020420\][data-v-de2a56d3]{--un-text-opacity:1;color:rgb(2 4 32/var(--un-text-opacity))}.text-\[\#64748B\][data-v-de2a56d3]{--un-text-opacity:1;color:rgb(100 116 139/var(--un-text-opacity))}.font-semibold[data-v-de2a56d3]{font-weight:600}.leading-none[data-v-de2a56d3]{line-height:1}.tracking-wide[data-v-de2a56d3]{letter-spacing:.025em}.font-sans[data-v-de2a56d3]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.tabular-nums[data-v-de2a56d3]{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)}.antialiased[data-v-de2a56d3]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media(prefers-color-scheme:dark){.dark\:bg-\[\#020420\][data-v-de2a56d3]{--un-bg-opacity:1;background-color:rgb(2 4 32/var(--un-bg-opacity))}.dark\:text-white[data-v-de2a56d3]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media(min-width:640px){.sm\:text-\[110px\][data-v-de2a56d3]{font-size:110px}.sm\:text-3xl[data-v-de2a56d3]{font-size:1.875rem;line-height:2.25rem}}
|
package/dist/client/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
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.Ci1pP-eR.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/
|
|
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.Ci1pP-eR.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__sitemap__/devtools/_nuxt/BZzBMR0a.js"><script type="module" src="/__sitemap__/devtools/_nuxt/BZzBMR0a.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script>window.__NUXT_SITE_CONFIG__={_priority:{name:-10,env:-15},env:"production",name:"@nuxtjs\u002Fsitemap-client"}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1767659687075,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__sitemap__/devtools",buildId:"c9c08595-dc8d-4073-931c-6ba959692bc1",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/sitemap.xml
CHANGED
package/dist/module.d.mts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions as ModuleOptions$1 } from '../dist/runtime/types.js';
|
|
2
|
+
import { ModuleOptions as ModuleOptions$1, ModuleRuntimeConfig } from '../dist/runtime/types.js';
|
|
3
3
|
export * from '../dist/runtime/types.js';
|
|
4
4
|
|
|
5
5
|
interface ModuleOptions extends ModuleOptions$1 {
|
|
6
6
|
}
|
|
7
|
+
interface ModuleHooks {
|
|
8
|
+
/**
|
|
9
|
+
* Hook called after the prerender of the sitemaps is done.
|
|
10
|
+
*/
|
|
11
|
+
'sitemap:prerender:done': (ctx: {
|
|
12
|
+
options: ModuleRuntimeConfig;
|
|
13
|
+
sitemaps: {
|
|
14
|
+
name: string;
|
|
15
|
+
readonly content: string;
|
|
16
|
+
}[];
|
|
17
|
+
}) => void | Promise<void>;
|
|
18
|
+
}
|
|
7
19
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
20
|
|
|
9
21
|
export { _default as default };
|
|
10
|
-
export type { ModuleOptions };
|
|
22
|
+
export type { ModuleHooks, ModuleOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions as ModuleOptions$1 } from '../dist/runtime/types.js';
|
|
2
|
+
import { ModuleOptions as ModuleOptions$1, ModuleRuntimeConfig } from '../dist/runtime/types.js';
|
|
3
3
|
export * from '../dist/runtime/types.js';
|
|
4
4
|
|
|
5
5
|
interface ModuleOptions extends ModuleOptions$1 {
|
|
6
6
|
}
|
|
7
|
+
interface ModuleHooks {
|
|
8
|
+
/**
|
|
9
|
+
* Hook called after the prerender of the sitemaps is done.
|
|
10
|
+
*/
|
|
11
|
+
'sitemap:prerender:done': (ctx: {
|
|
12
|
+
options: ModuleRuntimeConfig;
|
|
13
|
+
sitemaps: {
|
|
14
|
+
name: string;
|
|
15
|
+
readonly content: string;
|
|
16
|
+
}[];
|
|
17
|
+
}) => void | Promise<void>;
|
|
18
|
+
}
|
|
7
19
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
20
|
|
|
9
21
|
export { _default as default };
|
|
10
|
-
export type { ModuleOptions };
|
|
22
|
+
export type { ModuleHooks, ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { withSiteUrl, installNuxtSiteConfig } from 'nuxt-site-config/kit';
|
|
|
4
4
|
import { defu } from 'defu';
|
|
5
5
|
import { readPackageJSON } from 'pkg-types';
|
|
6
6
|
import { extname, dirname, relative } from 'pathe';
|
|
7
|
-
import { statSync, existsSync } from 'node:fs';
|
|
7
|
+
import { statSync, readFileSync, existsSync } from 'node:fs';
|
|
8
8
|
import { createPathFilter, splitForLocales, mergeOnKey } from '../dist/runtime/utils-pure.js';
|
|
9
9
|
import { provider, env } from 'std-env';
|
|
10
10
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
@@ -320,7 +320,9 @@ export async function readSourcesFromFilesystem(filename) {
|
|
|
320
320
|
videos: options.discoverVideos,
|
|
321
321
|
// TODO configurable?
|
|
322
322
|
lastmod: true,
|
|
323
|
-
|
|
323
|
+
// when autoI18n is enabled, let the sitemap builder generate alternatives
|
|
324
|
+
// based on i18n config instead of extracting from HTML (which can be incomplete)
|
|
325
|
+
alternatives: !options.autoI18n,
|
|
324
326
|
resolveUrl(s) {
|
|
325
327
|
return s.startsWith("/") ? withSiteUrl(s) : s;
|
|
326
328
|
}
|
|
@@ -352,10 +354,31 @@ export async function readSourcesFromFilesystem(filename) {
|
|
|
352
354
|
await mkdir(runtimeAssetsPath, { recursive: true });
|
|
353
355
|
await writeFile(join(runtimeAssetsPath, "global-sources.json"), JSON.stringify(globalSources));
|
|
354
356
|
await writeFile(join(runtimeAssetsPath, "child-sources.json"), JSON.stringify(childSources));
|
|
355
|
-
|
|
357
|
+
const sitemapEntry = options.isMultiSitemap ? "/sitemap_index.xml" : `/${Object.keys(options.sitemaps)[0]}`;
|
|
358
|
+
const sitemaps = await prerenderSitemapsFromEntry(nitro, sitemapEntry);
|
|
359
|
+
await nuxt.hooks.callHook("sitemap:prerender:done", { options, sitemaps });
|
|
356
360
|
});
|
|
357
361
|
});
|
|
358
362
|
}
|
|
363
|
+
async function prerenderSitemapsFromEntry(nitro, entry) {
|
|
364
|
+
const sitemaps = [];
|
|
365
|
+
const queue = [entry];
|
|
366
|
+
const processed = /* @__PURE__ */ new Set();
|
|
367
|
+
while (queue.length) {
|
|
368
|
+
const route = queue.shift();
|
|
369
|
+
if (processed.has(route)) continue;
|
|
370
|
+
processed.add(route);
|
|
371
|
+
const { filePath, prerenderUrls } = await prerenderRoute(nitro, route);
|
|
372
|
+
sitemaps.push({
|
|
373
|
+
name: route,
|
|
374
|
+
get content() {
|
|
375
|
+
return readFileSync(filePath, { encoding: "utf8" });
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
queue.push(...prerenderUrls);
|
|
379
|
+
}
|
|
380
|
+
return sitemaps;
|
|
381
|
+
}
|
|
359
382
|
async function prerenderRoute(nitro, route) {
|
|
360
383
|
const start = Date.now();
|
|
361
384
|
const _route = { route, fileName: route };
|
|
@@ -370,23 +393,18 @@ async function prerenderRoute(nitro, route) {
|
|
|
370
393
|
}
|
|
371
394
|
);
|
|
372
395
|
const header = res.headers.get("x-nitro-prerender") || "";
|
|
373
|
-
const prerenderUrls =
|
|
374
|
-
...header.split(",").map((i) => i.trim()).map((i) => decodeURIComponent(i)).filter(Boolean)
|
|
375
|
-
];
|
|
396
|
+
const prerenderUrls = header.split(",").map((i) => decodeURIComponent(i.trim())).filter(Boolean);
|
|
376
397
|
const filePath = join(nitro.options.output.publicDir, _route.fileName);
|
|
377
398
|
await mkdir(dirname(filePath), { recursive: true });
|
|
378
399
|
const data = res._data;
|
|
379
400
|
if (data === void 0)
|
|
380
401
|
throw new Error(`No data returned from '${fetchUrl}'`);
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
else
|
|
384
|
-
await writeFile(filePath, data, "utf8");
|
|
402
|
+
const content = filePath.endsWith("json") || typeof data === "object" ? JSON.stringify(data) : data;
|
|
403
|
+
await writeFile(filePath, content, "utf8");
|
|
385
404
|
_route.generateTimeMS = Date.now() - start;
|
|
386
405
|
nitro._prerenderedRoutes.push(_route);
|
|
387
406
|
nitro.logger.log(formatPrerenderRoute(_route));
|
|
388
|
-
|
|
389
|
-
await prerenderRoute(nitro, url);
|
|
407
|
+
return { filePath, prerenderUrls };
|
|
390
408
|
}
|
|
391
409
|
|
|
392
410
|
const DEVTOOLS_UI_ROUTE = "/__sitemap__/devtools";
|
|
@@ -557,7 +575,8 @@ const module$1 = defineNuxtModule({
|
|
|
557
575
|
exclude: ["/_**"],
|
|
558
576
|
// sources
|
|
559
577
|
sources: [],
|
|
560
|
-
excludeAppSources: []
|
|
578
|
+
excludeAppSources: [],
|
|
579
|
+
zeroRuntime: false
|
|
561
580
|
},
|
|
562
581
|
async setup(config, nuxt) {
|
|
563
582
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -750,7 +769,7 @@ const module$1 = defineNuxtModule({
|
|
|
750
769
|
'sitemap:output': (ctx: import('${typesPath}').SitemapOutputHookCtx) => void | Promise<void>
|
|
751
770
|
'sitemap:sources': (ctx: import('${typesPath}').SitemapSourcesHookCtx) => void | Promise<void>
|
|
752
771
|
}`;
|
|
753
|
-
return `// Generated by
|
|
772
|
+
return `// Generated by @nuxtjs/sitemap
|
|
754
773
|
declare module 'nitropack' {
|
|
755
774
|
${types}
|
|
756
775
|
}
|
|
@@ -767,11 +786,20 @@ export {}
|
|
|
767
786
|
`;
|
|
768
787
|
}
|
|
769
788
|
}, {
|
|
789
|
+
node: true,
|
|
770
790
|
nitro: true,
|
|
771
791
|
nuxt: true
|
|
772
792
|
});
|
|
773
793
|
const prerenderedRoutes = nuxt.options.nitro.prerender?.routes || [];
|
|
774
|
-
|
|
794
|
+
let prerenderSitemap = isNuxtGenerate() || includesSitemapRoot(config.sitemapName, prerenderedRoutes);
|
|
795
|
+
if (config.zeroRuntime && !prerenderSitemap) {
|
|
796
|
+
prerenderSitemap = true;
|
|
797
|
+
nuxt.options.nitro.prerender = nuxt.options.nitro.prerender || {};
|
|
798
|
+
nuxt.options.nitro.prerender.routes = nuxt.options.nitro.prerender.routes || [];
|
|
799
|
+
nuxt.options.nitro.prerender.routes.push("/sitemap.xml");
|
|
800
|
+
logger.info("`zeroRuntime` enabled - sitemap routes will be prerendered.");
|
|
801
|
+
}
|
|
802
|
+
const routesPath = config.zeroRuntime ? "./runtime/server/routes/__zero-runtime" : "./runtime/server/routes";
|
|
775
803
|
const routeRules = {};
|
|
776
804
|
nuxt.options.nitro.routeRules = nuxt.options.nitro.routeRules || {};
|
|
777
805
|
if (prerenderSitemap) {
|
|
@@ -807,10 +835,14 @@ export {}
|
|
|
807
835
|
} else {
|
|
808
836
|
nuxt.options.nitro.routeRules[`/${config.sitemapName}`] = routeRules;
|
|
809
837
|
}
|
|
810
|
-
if (config.experimentalWarmUp)
|
|
811
|
-
|
|
812
|
-
if (config.
|
|
813
|
-
|
|
838
|
+
if (config.zeroRuntime && (config.experimentalWarmUp || config.experimentalCompression))
|
|
839
|
+
logger.warn("`experimentalWarmUp` and `experimentalCompression` are ignored in zeroRuntime mode.");
|
|
840
|
+
if (!config.zeroRuntime) {
|
|
841
|
+
if (config.experimentalWarmUp)
|
|
842
|
+
addServerPlugin(resolve("./runtime/server/plugins/warm-up"));
|
|
843
|
+
if (config.experimentalCompression)
|
|
844
|
+
addServerPlugin(resolve("./runtime/server/plugins/compression"));
|
|
845
|
+
}
|
|
814
846
|
const isNuxtContentDocumentDriven = !!nuxt.options.content?.documentDriven || config.strictNuxtContentPaths;
|
|
815
847
|
const usingNuxtContent = hasNuxtModule("@nuxt/content");
|
|
816
848
|
const isNuxtContentV3 = usingNuxtContent && await hasNuxtModuleCompatibility("@nuxt/content", "^3");
|
|
@@ -904,36 +936,49 @@ export {}
|
|
|
904
936
|
if (usingMultiSitemaps) {
|
|
905
937
|
addServerHandler({
|
|
906
938
|
route: "/sitemap_index.xml",
|
|
907
|
-
handler: resolve(
|
|
939
|
+
handler: resolve(`${routesPath}/sitemap_index.xml`),
|
|
908
940
|
lazy: true,
|
|
909
941
|
middleware: false
|
|
910
942
|
});
|
|
911
943
|
if (config.sitemapsPathPrefix && config.sitemapsPathPrefix !== "/") {
|
|
912
944
|
addServerHandler({
|
|
913
945
|
route: joinURL(config.sitemapsPathPrefix, `/**:sitemap`),
|
|
914
|
-
handler: resolve(
|
|
946
|
+
handler: resolve(`${routesPath}/sitemap/[sitemap].xml`),
|
|
915
947
|
lazy: true,
|
|
916
948
|
middleware: false
|
|
917
949
|
});
|
|
918
950
|
} else {
|
|
919
951
|
const sitemapNames = Object.keys(config.sitemaps || {});
|
|
952
|
+
let hasChunkedSitemaps = false;
|
|
920
953
|
for (const sitemapName of sitemapNames) {
|
|
921
954
|
if (sitemapName === "index")
|
|
922
955
|
continue;
|
|
923
956
|
const sitemapConfig = config.sitemaps[sitemapName];
|
|
924
957
|
addServerHandler({
|
|
925
958
|
route: withLeadingSlash(`${sitemapName}.xml`),
|
|
926
|
-
handler: resolve(
|
|
959
|
+
handler: resolve(`${routesPath}/sitemap/[sitemap].xml`),
|
|
927
960
|
lazy: true,
|
|
928
961
|
middleware: false
|
|
929
962
|
});
|
|
930
|
-
if (sitemapConfig.chunks)
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
963
|
+
if (sitemapConfig.chunks)
|
|
964
|
+
hasChunkedSitemaps = true;
|
|
965
|
+
}
|
|
966
|
+
if (hasChunkedSitemaps) {
|
|
967
|
+
const maxChunks = 20;
|
|
968
|
+
for (const sitemapName of sitemapNames) {
|
|
969
|
+
if (sitemapName === "index")
|
|
970
|
+
continue;
|
|
971
|
+
const sitemapConfig = config.sitemaps[sitemapName];
|
|
972
|
+
if (sitemapConfig.chunks) {
|
|
973
|
+
for (let i = 0; i < maxChunks; i++) {
|
|
974
|
+
addServerHandler({
|
|
975
|
+
route: `/${sitemapName}-${i}.xml`,
|
|
976
|
+
handler: resolve(`${routesPath}/sitemap/[sitemap].xml`),
|
|
977
|
+
lazy: true,
|
|
978
|
+
middleware: false
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
937
982
|
}
|
|
938
983
|
}
|
|
939
984
|
}
|
|
@@ -1075,7 +1120,7 @@ export {}
|
|
|
1075
1120
|
if (resolvedAutoI18n)
|
|
1076
1121
|
runtimeConfig.autoI18n = resolvedAutoI18n;
|
|
1077
1122
|
nuxt.options.runtimeConfig.sitemap = runtimeConfig;
|
|
1078
|
-
if (config.debug || nuxt.options.dev) {
|
|
1123
|
+
if ((config.debug || nuxt.options.dev) && !config.zeroRuntime) {
|
|
1079
1124
|
addServerHandler({
|
|
1080
1125
|
route: "/__sitemap__/debug.json",
|
|
1081
1126
|
handler: resolve("./runtime/server/routes/__sitemap__/debug")
|
|
@@ -1271,9 +1316,16 @@ export async function readSourcesFromFilesystem() {
|
|
|
1271
1316
|
}
|
|
1272
1317
|
addServerHandler({
|
|
1273
1318
|
route: `/${config.sitemapName}`,
|
|
1274
|
-
handler: resolve(
|
|
1319
|
+
handler: resolve(`${routesPath}/sitemap.xml`)
|
|
1275
1320
|
});
|
|
1276
1321
|
setupPrerenderHandler({ runtimeConfig, logger, generateGlobalSources, generateChildSources });
|
|
1322
|
+
if (!config.zeroRuntime && !nuxt.options.dev && !nuxt.options._prepare) {
|
|
1323
|
+
const hasDynamicSource = (source) => typeof source === "string" || Array.isArray(source) || !!source.fetch;
|
|
1324
|
+
const globalHasFetch = (config.sources || []).some(hasDynamicSource);
|
|
1325
|
+
const sitemapsHaveFetch = typeof config.sitemaps === "object" && Object.values(config.sitemaps).some((s) => s && "sources" in s && (s.sources || []).some(hasDynamicSource));
|
|
1326
|
+
if (!globalHasFetch && !sitemapsHaveFetch)
|
|
1327
|
+
logger.info("No dynamic sources detected. Consider enabling `zeroRuntime` to reduce server bundle size. See https://nuxtseo.com/sitemap/guides/zero-runtime");
|
|
1328
|
+
}
|
|
1277
1329
|
}
|
|
1278
1330
|
});
|
|
1279
1331
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createError, defineEventHandler } from "h3";
|
|
2
|
+
export default defineEventHandler(async (e) => {
|
|
3
|
+
if (import.meta.dev || import.meta.prerender) {
|
|
4
|
+
const { sitemapChildXmlEventHandler } = await import("../../../sitemap/event-handlers.js");
|
|
5
|
+
return sitemapChildXmlEventHandler(e);
|
|
6
|
+
}
|
|
7
|
+
throw createError({ statusCode: 500, message: "Sitemap not prerendered. zeroRuntime requires prerendering." });
|
|
8
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createError, defineEventHandler } from "h3";
|
|
2
|
+
export default defineEventHandler(async (e) => {
|
|
3
|
+
if (import.meta.dev || import.meta.prerender) {
|
|
4
|
+
const { sitemapXmlEventHandler } = await import("../../sitemap/event-handlers.js");
|
|
5
|
+
return sitemapXmlEventHandler(e);
|
|
6
|
+
}
|
|
7
|
+
throw createError({ statusCode: 500, message: "Sitemap not prerendered. zeroRuntime requires prerendering." });
|
|
8
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createError, defineEventHandler } from "h3";
|
|
2
|
+
export default defineEventHandler(async (e) => {
|
|
3
|
+
if (import.meta.dev || import.meta.prerender) {
|
|
4
|
+
const { sitemapIndexXmlEventHandler } = await import("../../sitemap/event-handlers.js");
|
|
5
|
+
return sitemapIndexXmlEventHandler(e);
|
|
6
|
+
}
|
|
7
|
+
throw createError({ statusCode: 500, message: "Sitemap not prerendered. zeroRuntime requires prerendering." });
|
|
8
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string |
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { createSitemap } from "../../sitemap/nitro.js";
|
|
5
|
-
import { parseChunkInfo, getSitemapConfig } from "../../sitemap/utils/chunk.js";
|
|
6
|
-
export default defineEventHandler(async (e) => {
|
|
7
|
-
const runtimeConfig = useSitemapRuntimeConfig(e);
|
|
8
|
-
const { sitemaps } = runtimeConfig;
|
|
9
|
-
let sitemapName = getRouterParam(e, "sitemap");
|
|
10
|
-
if (!sitemapName) {
|
|
11
|
-
const path = e.path;
|
|
12
|
-
const match = path.match(/(?:\/__sitemap__\/)?([^/]+)\.xml$/);
|
|
13
|
-
if (match) {
|
|
14
|
-
sitemapName = match[1];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (!sitemapName) {
|
|
18
|
-
return createError({
|
|
19
|
-
statusCode: 400,
|
|
20
|
-
message: "Invalid sitemap request"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
sitemapName = withoutLeadingSlash(withoutTrailingSlash(sitemapName.replace(".xml", "").replace("__sitemap__/", "").replace(runtimeConfig.sitemapsPathPrefix || "", "")));
|
|
24
|
-
const chunkInfo = parseChunkInfo(sitemapName, sitemaps, runtimeConfig.defaultSitemapsChunkSize);
|
|
25
|
-
const isAutoChunked = typeof sitemaps.chunks !== "undefined" && !Number.isNaN(Number(sitemapName));
|
|
26
|
-
const sitemapExists = sitemapName in sitemaps || chunkInfo.baseSitemapName in sitemaps || isAutoChunked;
|
|
27
|
-
if (!sitemapExists) {
|
|
28
|
-
return createError({
|
|
29
|
-
statusCode: 404,
|
|
30
|
-
message: `Sitemap "${sitemapName}" not found.`
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (chunkInfo.isChunked && chunkInfo.chunkIndex !== void 0) {
|
|
34
|
-
const baseSitemap = sitemaps[chunkInfo.baseSitemapName];
|
|
35
|
-
if (baseSitemap && !baseSitemap.chunks && !baseSitemap._isChunking) {
|
|
36
|
-
return createError({
|
|
37
|
-
statusCode: 404,
|
|
38
|
-
message: `Sitemap "${chunkInfo.baseSitemapName}" does not support chunking.`
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (baseSitemap?._chunkCount !== void 0 && chunkInfo.chunkIndex >= baseSitemap._chunkCount) {
|
|
42
|
-
return createError({
|
|
43
|
-
statusCode: 404,
|
|
44
|
-
message: `Chunk ${chunkInfo.chunkIndex} does not exist for sitemap "${chunkInfo.baseSitemapName}".`
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const sitemapConfig = getSitemapConfig(sitemapName, sitemaps, runtimeConfig.defaultSitemapsChunkSize || void 0);
|
|
49
|
-
return createSitemap(e, sitemapConfig, runtimeConfig);
|
|
50
|
-
});
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { sitemapChildXmlEventHandler } from "../../sitemap/event-handlers.js";
|
|
3
|
+
export default defineEventHandler(sitemapChildXmlEventHandler);
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { useSitemapRuntimeConfig } from "../utils.js";
|
|
5
|
-
import { createSitemap } from "../sitemap/nitro.js";
|
|
6
|
-
export default defineEventHandler(async (e) => {
|
|
7
|
-
const runtimeConfig = useSitemapRuntimeConfig();
|
|
8
|
-
const { sitemaps } = runtimeConfig;
|
|
9
|
-
if ("index" in sitemaps) {
|
|
10
|
-
return sendRedirect(e, withBase("/sitemap_index.xml", useRuntimeConfig().app.baseURL), import.meta.dev ? 302 : 301);
|
|
11
|
-
}
|
|
12
|
-
return createSitemap(e, Object.values(sitemaps)[0], runtimeConfig);
|
|
13
|
-
});
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { sitemapXmlEventHandler } from "../sitemap/event-handlers.js";
|
|
3
|
+
export default defineEventHandler(sitemapXmlEventHandler);
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { useSitemapRuntimeConfig } from "../utils.js";
|
|
5
|
-
import { buildSitemapIndex, urlsToIndexXml } from "../sitemap/builder/sitemap-index.js";
|
|
6
|
-
import { useNitroUrlResolvers } from "../sitemap/nitro.js";
|
|
7
|
-
export default defineEventHandler(async (e) => {
|
|
8
|
-
const runtimeConfig = useSitemapRuntimeConfig();
|
|
9
|
-
const nitro = useNitroApp();
|
|
10
|
-
const resolvers = useNitroUrlResolvers(e);
|
|
11
|
-
const { entries: sitemaps, failedSources } = await buildSitemapIndex(resolvers, runtimeConfig, nitro);
|
|
12
|
-
if (import.meta.prerender) {
|
|
13
|
-
appendHeader(
|
|
14
|
-
e,
|
|
15
|
-
"x-nitro-prerender",
|
|
16
|
-
sitemaps.filter((entry) => !!entry._sitemapName).map((entry) => encodeURIComponent(joinURL(runtimeConfig.sitemapsPathPrefix || "", `/${entry._sitemapName}.xml`))).join(", ")
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
const indexResolvedCtx = { sitemaps, event: e };
|
|
20
|
-
await nitro.hooks.callHook("sitemap:index-resolved", indexResolvedCtx);
|
|
21
|
-
const errorInfo = failedSources.length > 0 ? {
|
|
22
|
-
messages: failedSources.map((f) => f.error),
|
|
23
|
-
urls: failedSources.map((f) => f.url)
|
|
24
|
-
} : void 0;
|
|
25
|
-
const output = urlsToIndexXml(indexResolvedCtx.sitemaps, resolvers, runtimeConfig, errorInfo);
|
|
26
|
-
const ctx = { sitemap: output, sitemapName: "sitemap", event: e };
|
|
27
|
-
await nitro.hooks.callHook("sitemap:output", ctx);
|
|
28
|
-
setHeader(e, "Content-Type", "text/xml; charset=UTF-8");
|
|
29
|
-
if (runtimeConfig.cacheMaxAgeSeconds) {
|
|
30
|
-
setHeader(e, "Cache-Control", `public, max-age=${runtimeConfig.cacheMaxAgeSeconds}, s-maxage=${runtimeConfig.cacheMaxAgeSeconds}, stale-while-revalidate=3600`);
|
|
31
|
-
const now = /* @__PURE__ */ new Date();
|
|
32
|
-
setHeader(e, "X-Sitemap-Generated", now.toISOString());
|
|
33
|
-
setHeader(e, "X-Sitemap-Cache-Duration", `${runtimeConfig.cacheMaxAgeSeconds}s`);
|
|
34
|
-
const expiryTime = new Date(now.getTime() + runtimeConfig.cacheMaxAgeSeconds * 1e3);
|
|
35
|
-
setHeader(e, "X-Sitemap-Cache-Expires", expiryTime.toISOString());
|
|
36
|
-
const remainingSeconds = Math.floor((expiryTime.getTime() - now.getTime()) / 1e3);
|
|
37
|
-
setHeader(e, "X-Sitemap-Cache-Remaining", `${remainingSeconds}s`);
|
|
38
|
-
} else {
|
|
39
|
-
setHeader(e, "Cache-Control", `no-cache, no-store`);
|
|
40
|
-
}
|
|
41
|
-
return ctx.sitemap;
|
|
42
|
-
});
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { sitemapIndexXmlEventHandler } from "../sitemap/event-handlers.js";
|
|
3
|
+
export default defineEventHandler(sitemapIndexXmlEventHandler);
|
|
@@ -3,12 +3,8 @@ import { joinURL, withHttps } from "ufo";
|
|
|
3
3
|
import { preNormalizeEntry } from "../urlset/normalise.js";
|
|
4
4
|
import { childSitemapSources, globalSitemapSources, resolveSitemapSources } from "../urlset/sources.js";
|
|
5
5
|
import { sortInPlace } from "../urlset/sort.js";
|
|
6
|
-
import { createPathFilter, splitForLocales } from "../../../utils-pure.js";
|
|
6
|
+
import { applyDynamicParams, createPathFilter, findPageMapping, splitForLocales } from "../../../utils-pure.js";
|
|
7
7
|
import { parseChunkInfo, sliceUrlsForChunk } from "../utils/chunk.js";
|
|
8
|
-
function getPageKey(pathWithoutPrefix) {
|
|
9
|
-
const stripped = pathWithoutPrefix[0] === "/" ? pathWithoutPrefix.slice(1) : pathWithoutPrefix;
|
|
10
|
-
return stripped.endsWith("/index") ? stripped.slice(0, -6) || "index" : stripped || "index";
|
|
11
|
-
}
|
|
12
8
|
export function resolveSitemapEntries(sitemap, urls, runtimeConfig, resolvers) {
|
|
13
9
|
const {
|
|
14
10
|
autoI18n,
|
|
@@ -91,18 +87,21 @@ export function resolveSitemapEntries(sitemap, urls, runtimeConfig, resolvers) {
|
|
|
91
87
|
};
|
|
92
88
|
});
|
|
93
89
|
} else {
|
|
94
|
-
const
|
|
95
|
-
const pageMappings = hasPages ? autoI18n.pages[pageKey] : void 0;
|
|
90
|
+
const pageMatch = hasPages ? findPageMapping(e._pathWithoutPrefix, autoI18n.pages) : null;
|
|
96
91
|
const pathSearch = e._path?.search || "";
|
|
97
92
|
const pathWithoutPrefix = e._pathWithoutPrefix;
|
|
98
93
|
for (const l of autoI18n.locales) {
|
|
99
94
|
let loc = pathWithoutPrefix;
|
|
100
|
-
if (
|
|
101
|
-
const customPath =
|
|
95
|
+
if (pageMatch && pageMatch.mappings[l.code] !== void 0) {
|
|
96
|
+
const customPath = pageMatch.mappings[l.code];
|
|
102
97
|
if (customPath === false)
|
|
103
98
|
continue;
|
|
104
|
-
if (typeof customPath === "string")
|
|
99
|
+
if (typeof customPath === "string") {
|
|
105
100
|
loc = customPath[0] === "/" ? customPath : `/${customPath}`;
|
|
101
|
+
loc = applyDynamicParams(loc, pageMatch.paramSegments);
|
|
102
|
+
if (isPrefixStrategy || isPrefixExceptOrAndDefault && l.code !== defaultLocale)
|
|
103
|
+
loc = joinURL(`/${l.code}`, loc);
|
|
104
|
+
}
|
|
106
105
|
} else if (!hasDifferentDomains && !(isPrefixExceptOrAndDefault && l.code === defaultLocale)) {
|
|
107
106
|
loc = joinURL(`/${l.code}`, pathWithoutPrefix);
|
|
108
107
|
}
|
|
@@ -112,12 +111,16 @@ export function resolveSitemapEntries(sitemap, urls, runtimeConfig, resolvers) {
|
|
|
112
111
|
const code = locale.code === "x-default" ? defaultLocale : locale.code;
|
|
113
112
|
const isDefault = locale.code === "x-default" || locale.code === defaultLocale;
|
|
114
113
|
let href = pathWithoutPrefix;
|
|
115
|
-
if (
|
|
116
|
-
const customPath =
|
|
114
|
+
if (pageMatch && pageMatch.mappings[code] !== void 0) {
|
|
115
|
+
const customPath = pageMatch.mappings[code];
|
|
117
116
|
if (customPath === false)
|
|
118
117
|
continue;
|
|
119
|
-
if (typeof customPath === "string")
|
|
118
|
+
if (typeof customPath === "string") {
|
|
120
119
|
href = customPath[0] === "/" ? customPath : `/${customPath}`;
|
|
120
|
+
href = applyDynamicParams(href, pageMatch.paramSegments);
|
|
121
|
+
if (isPrefixStrategy || isPrefixExceptOrAndDefault && !isDefault)
|
|
122
|
+
href = joinURL("/", code, href);
|
|
123
|
+
}
|
|
121
124
|
} else if (isPrefixStrategy) {
|
|
122
125
|
href = joinURL("/", code, pathWithoutPrefix);
|
|
123
126
|
} else if (isPrefixExceptOrAndDefault && !isDefault) {
|
|
@@ -14,7 +14,7 @@ function buildUrlXml(url, NL, I1, I2, I3, I4) {
|
|
|
14
14
|
if (url.changefreq) xml += `${I2}<changefreq>${url.changefreq}</changefreq>${NL}`;
|
|
15
15
|
if (url.priority !== void 0) {
|
|
16
16
|
const p = typeof url.priority === "number" ? url.priority : Number.parseFloat(url.priority);
|
|
17
|
-
xml += `${I2}<priority>${p
|
|
17
|
+
xml += `${I2}<priority>${p.toFixed(1)}</priority>${NL}`;
|
|
18
18
|
}
|
|
19
19
|
if (url.alternatives) {
|
|
20
20
|
for (const alt of url.alternatives) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
export declare function sitemapXmlEventHandler(e: H3Event): Promise<string | void>;
|
|
3
|
+
export declare function sitemapIndexXmlEventHandler(e: H3Event): Promise<string>;
|
|
4
|
+
export declare function sitemapChildXmlEventHandler(e: H3Event): Promise<string | undefined>;
|