nuxt-ai-ready 3.6.1 → 3.6.2
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/agent-skills-config-CmZq9uWW.mjs +18 -0
- package/dist/agent-skills-zGLgFB6H.mjs +468 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +656 -570
- package/dist/devtools/pages/ai-ready/debug.vue +9 -3
- package/dist/devtools/pages/ai-ready/index.vue +3 -1
- package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
- package/dist/devtools/pages/ai-ready.vue +28 -4
- package/dist/module.d.mts +106 -112
- package/dist/module.json +3 -3
- package/dist/module.mjs +2732 -26
- package/dist/package-metadata-B1darl8W.mjs +28 -0
- package/dist/prerender-QMv07W4h.mjs +650 -0
- package/dist/runtime/app/composables/webmcp.js +90 -97
- package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
- package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
- package/dist/runtime/app/plugins/webmcp.client.js +49 -53
- package/dist/runtime/app/webmcp-config.js +2 -2
- package/dist/runtime/cache-control.js +16 -10
- package/dist/runtime/i18n-url.js +6 -6
- package/dist/runtime/index.js +4 -12
- package/dist/runtime/llms-txt-directive.js +20 -13
- package/dist/runtime/llms-txt-files.js +188 -187
- package/dist/runtime/llms-txt-format.js +54 -55
- package/dist/runtime/llms-txt-i18n.js +22 -19
- package/dist/runtime/llms-txt-utils.js +140 -95
- package/dist/runtime/markdown-links.js +45 -39
- package/dist/runtime/markdown-path.js +29 -9
- package/dist/runtime/markdown-text.js +2 -1
- package/dist/runtime/mcp.js +5 -1
- package/dist/runtime/route-path.js +14 -8
- package/dist/runtime/server/db/drizzle/client.js +71 -75
- package/dist/runtime/server/db/drizzle/index.js +16 -28
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
- package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
- package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
- package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
- package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
- package/dist/runtime/server/db/drizzle/queries.js +633 -532
- package/dist/runtime/server/db/drizzle/raw.js +200 -176
- package/dist/runtime/server/db/index.js +3 -0
- package/dist/runtime/server/db/queries.js +816 -607
- package/dist/runtime/server/db/schema/postgres.js +56 -50
- package/dist/runtime/server/db/schema/sqlite.js +56 -50
- package/dist/runtime/server/db/schema-sql.js +35 -38
- package/dist/runtime/server/db/seed.js +60 -45
- package/dist/runtime/server/db/shared.js +300 -213
- package/dist/runtime/server/index.js +1 -17
- package/dist/runtime/server/mcp/cache-key.js +5 -1
- package/dist/runtime/server/mcp/resources/pages.js +32 -33
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
- package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
- package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
- package/dist/runtime/server/middleware/markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.js +15 -13
- package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
- package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/render-markdown.js +164 -144
- package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
- package/dist/runtime/server/plugins/ai-terms.js +4 -8
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
- package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
- package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
- package/dist/runtime/server/plugins/link-header.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header.js +30 -30
- package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
- package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
- package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
- package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
- package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
- package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
- package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
- package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
- package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
- package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
- package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
- package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
- package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
- package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
- package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
- package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
- package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
- package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
- package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +8 -6
- package/dist/runtime/server/routes/ai-catalog.js +19 -19
- package/dist/runtime/server/routes/ai-terms.js +23 -19
- package/dist/runtime/server/routes/api-catalog.js +23 -23
- package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
- package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms.txt.get.js +38 -33
- package/dist/runtime/server/routes/mcp-server-card.js +19 -19
- package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
- package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
- package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
- package/dist/runtime/server/utils/auth.js +76 -53
- package/dist/runtime/server/utils/batchIndex.js +72 -60
- package/dist/runtime/server/utils/checkStale.js +181 -134
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
- package/dist/runtime/server/utils/cloudflare.js +69 -51
- package/dist/runtime/server/utils/content-negotiation.js +30 -18
- package/dist/runtime/server/utils/content.js +4 -1
- package/dist/runtime/server/utils/context.js +30 -19
- package/dist/runtime/server/utils/cron-plan.js +6 -6
- package/dist/runtime/server/utils/discovery-response.js +5 -6
- package/dist/runtime/server/utils/fetch.js +2 -1
- package/dist/runtime/server/utils/frontmatter.js +44 -57
- package/dist/runtime/server/utils/i18n.js +3 -8
- package/dist/runtime/server/utils/indexPage.js +152 -113
- package/dist/runtime/server/utils/keywords.js +278 -277
- package/dist/runtime/server/utils/link-header.js +67 -56
- package/dist/runtime/server/utils/llms-full.js +39 -49
- package/dist/runtime/server/utils/markdown-redirect.js +26 -14
- package/dist/runtime/server/utils/markdown-request.js +62 -47
- package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
- package/dist/runtime/server/utils/negotiation-decision.js +106 -34
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +195 -144
- package/dist/runtime/server/utils/page-updated-at.js +23 -15
- package/dist/runtime/server/utils/prerender-html.js +31 -17
- package/dist/runtime/server/utils/runCron.js +263 -192
- package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
- package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
- package/dist/runtime/server/utils/sitemap-md.js +39 -50
- package/dist/runtime/server/utils/sitemap-routes.js +7 -7
- package/dist/runtime/server/utils/sitemap.js +459 -414
- package/dist/runtime/server/utils.js +141 -122
- package/dist/runtime/site-tool-catalog.js +39 -43
- package/dist/runtime/site-tool-config.js +1 -0
- package/dist/runtime/sync-secret.js +11 -11
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/webmcp-site-tools.js +278 -250
- package/dist/runtime/webmcp.js +53 -42
- package/dist/static-headers-G7hFL3wE.mjs +328 -0
- package/dist/types.d.mts +1 -9
- package/package.json +18 -22
- package/skills/nuxt-ai-ready/SKILL.md +8 -2
- package/dist/chunks/agent-skills.mjs +0 -383
- package/dist/chunks/prerender.mjs +0 -683
- package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
- package/dist/shared/nuxt-ai-ready.DCd-1s1G.mjs +0 -29
|
@@ -11,459 +11,504 @@ import { stripIndexedSitemapLastmods } from "./sitemap-lastmod.js";
|
|
|
11
11
|
const FETCH_TIMEOUT = 15e3;
|
|
12
12
|
const SITEMAP_FALLBACK_ORIGIN = "http://localhost";
|
|
13
13
|
const SITEMAP_READER_LIMITS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
maxRedirects: 5,
|
|
15
|
+
maxDocuments: 100,
|
|
16
|
+
maxDepth: 3,
|
|
17
|
+
maxUrls: 5e4,
|
|
18
|
+
maxEntries: 5e4,
|
|
19
|
+
maxWireBytes: 50 * 1024 * 1024,
|
|
20
|
+
maxDecodedBytes: 50 * 1024 * 1024
|
|
21
21
|
};
|
|
22
22
|
const MAX_SITEMAP_CRAWL_ROUNDS = 10;
|
|
23
|
+
/**
|
|
24
|
+
* Get list of sitemaps from @nuxtjs/sitemap runtime config
|
|
25
|
+
* Returns empty array if sitemap module not configured
|
|
26
|
+
*/
|
|
23
27
|
export function getSitemapsFromConfig(event) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
const runtimeConfig = useRuntimeConfig(event);
|
|
29
|
+
const sitemapConfig = {
|
|
30
|
+
...staticSitemapConfig,
|
|
31
|
+
...runtimeConfig.sitemap
|
|
32
|
+
};
|
|
33
|
+
if (!sitemapConfig?.sitemaps) return [];
|
|
34
|
+
const sitemaps = [];
|
|
35
|
+
for (const [key, sitemap] of Object.entries(sitemapConfig.sitemaps)) {
|
|
36
|
+
// Skip 'index' entry (sitemap index, not actual sitemap)
|
|
37
|
+
if (key === "index") continue;
|
|
38
|
+
// Automatic chunks have no route. Their index is the discovery root.
|
|
39
|
+
const route = sitemap._route || sitemap.route || (key === "chunks" ? sitemapConfig.sitemaps.index?._route || sitemapConfig.sitemaps.index?.route : undefined);
|
|
40
|
+
if (route) {
|
|
41
|
+
sitemaps.push({
|
|
42
|
+
name: (sitemap.sitemapName || key).replace(/\.xml$/, ""),
|
|
43
|
+
route: route.startsWith("/") ? route : `/${route}`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return sitemaps;
|
|
41
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if site has multiple sitemaps configured
|
|
51
|
+
*/
|
|
42
52
|
export function hasMultipleSitemaps(event) {
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
const sitemaps = getSitemapsFromConfig(event);
|
|
54
|
+
return sitemaps.length > 1;
|
|
45
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Normalize sitemap URL entries to SitemapUrl[]
|
|
58
|
+
*/
|
|
46
59
|
function normalizeUrl(entry) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
return {
|
|
61
|
+
loc: entry.loc,
|
|
62
|
+
lastmod: entry.lastmod
|
|
63
|
+
};
|
|
51
64
|
}
|
|
52
65
|
function parseAbsoluteUrl(input, base) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
try {
|
|
67
|
+
return {
|
|
68
|
+
_tag: "ok",
|
|
69
|
+
value: new URL(input, base)
|
|
70
|
+
};
|
|
71
|
+
} catch {
|
|
72
|
+
return {
|
|
73
|
+
_tag: "error",
|
|
74
|
+
input
|
|
75
|
+
};
|
|
76
|
+
}
|
|
58
77
|
}
|
|
59
78
|
function responseBody(response) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return response.body;
|
|
79
|
+
const data = response._data;
|
|
80
|
+
if (data && typeof data.getReader === "function") return data;
|
|
81
|
+
return response.body;
|
|
64
82
|
}
|
|
65
83
|
async function cancelBody(body, reason) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
if (!body) return;
|
|
85
|
+
await body.cancel(reason).catch((error) => {
|
|
86
|
+
// Cleanup failure cannot change the established HTTP result.
|
|
87
|
+
logger.debug(`[sitemap] Failed to cancel response body: ${String(error)}`);
|
|
88
|
+
});
|
|
71
89
|
}
|
|
72
90
|
async function readBoundedBody(body, maxWireBytes) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
if (!body) {
|
|
92
|
+
return {
|
|
93
|
+
_tag: "ok",
|
|
94
|
+
body: new Uint8Array()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const reader = body.getReader();
|
|
98
|
+
const chunks = [];
|
|
99
|
+
let bytesRead = 0;
|
|
100
|
+
let reachedEnd = false;
|
|
101
|
+
let exceeded = false;
|
|
102
|
+
try {
|
|
103
|
+
while (!reachedEnd) {
|
|
104
|
+
const next = await reader.read();
|
|
105
|
+
reachedEnd = next.done;
|
|
106
|
+
if (!next.value) continue;
|
|
107
|
+
bytesRead += next.value.byteLength;
|
|
108
|
+
if (bytesRead > maxWireBytes) {
|
|
109
|
+
exceeded = true;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
chunks.push(next.value);
|
|
113
|
+
}
|
|
114
|
+
} finally {
|
|
115
|
+
if (!reachedEnd) {
|
|
116
|
+
await reader.cancel("sitemap wire limit reached").catch((error) => {
|
|
117
|
+
// Cleanup failure cannot change the established wire-limit result.
|
|
118
|
+
logger.debug(`[sitemap] Failed to cancel bounded response body: ${String(error)}`);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
reader.releaseLock();
|
|
122
|
+
}
|
|
123
|
+
if (exceeded) return {
|
|
124
|
+
_tag: "limit",
|
|
125
|
+
bytesRead
|
|
126
|
+
};
|
|
127
|
+
const output = new Uint8Array(bytesRead);
|
|
128
|
+
let offset = 0;
|
|
129
|
+
for (const chunk of chunks) {
|
|
130
|
+
output.set(chunk, offset);
|
|
131
|
+
offset += chunk.byteLength;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
_tag: "ok",
|
|
135
|
+
body: output
|
|
136
|
+
};
|
|
110
137
|
}
|
|
111
138
|
async function fetchLocalRoute(event, route, usePublicAsset, request) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})).finally(() => {
|
|
147
|
-
clearTimeout(timeout);
|
|
148
|
-
request.signal?.removeEventListener("abort", abortFromRequest);
|
|
149
|
-
});
|
|
139
|
+
const controller = new AbortController();
|
|
140
|
+
let timedOut = false;
|
|
141
|
+
const abortFromRequest = () => controller.abort(request.signal?.reason);
|
|
142
|
+
if (request.signal?.aborted) abortFromRequest();
|
|
143
|
+
else request.signal?.addEventListener("abort", abortFromRequest, { once: true });
|
|
144
|
+
const timeout = setTimeout(() => {
|
|
145
|
+
timedOut = true;
|
|
146
|
+
controller.abort(new DOMException("Sitemap fetch timed out", "TimeoutError"));
|
|
147
|
+
}, FETCH_TIMEOUT);
|
|
148
|
+
const fetchPromise = usePublicAsset ? getCfEnv(event).ASSETS.fetch(new Request(new URL(route, "https://assets.local"), {
|
|
149
|
+
redirect: "manual",
|
|
150
|
+
signal: controller.signal
|
|
151
|
+
})) : event ? fetchRawWithEvent(event, route, {
|
|
152
|
+
redirect: "manual",
|
|
153
|
+
signal: controller.signal
|
|
154
|
+
}) : globalThis.$fetch.raw(route, {
|
|
155
|
+
responseType: "stream",
|
|
156
|
+
redirect: "manual",
|
|
157
|
+
retry: false,
|
|
158
|
+
ignoreResponseError: true,
|
|
159
|
+
signal: controller.signal
|
|
160
|
+
});
|
|
161
|
+
return fetchPromise.then((response) => ({
|
|
162
|
+
_tag: "ok",
|
|
163
|
+
response
|
|
164
|
+
})).catch((error) => ({
|
|
165
|
+
_tag: "error",
|
|
166
|
+
error,
|
|
167
|
+
timedOut,
|
|
168
|
+
cancelled: Boolean(request.signal?.aborted)
|
|
169
|
+
})).finally(() => {
|
|
170
|
+
clearTimeout(timeout);
|
|
171
|
+
request.signal?.removeEventListener("abort", abortFromRequest);
|
|
172
|
+
});
|
|
150
173
|
}
|
|
151
174
|
function createLocalSitemapLoader(event, usePublicAsset, loadedBodies) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
175
|
+
return async (request) => {
|
|
176
|
+
const parsed = parseAbsoluteUrl(request.url);
|
|
177
|
+
if (parsed._tag === "error") {
|
|
178
|
+
return {
|
|
179
|
+
_tag: "load_error",
|
|
180
|
+
url: request.url,
|
|
181
|
+
code: "network",
|
|
182
|
+
detail: `Invalid sitemap URL: ${request.url}`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const route = `${parsed.value.pathname}${parsed.value.search}`;
|
|
186
|
+
logger.debug(`[sitemap] Fetching ${route} via ${usePublicAsset ? "ASSETS.fetch" : event ? "event.fetch" : "globalThis.$fetch"}`);
|
|
187
|
+
const fetched = await fetchLocalRoute(event, route, usePublicAsset, request);
|
|
188
|
+
if (fetched._tag === "error") {
|
|
189
|
+
return {
|
|
190
|
+
_tag: "load_error",
|
|
191
|
+
url: request.url,
|
|
192
|
+
code: fetched.timedOut ? "timeout" : fetched.cancelled ? "cancelled" : "network",
|
|
193
|
+
detail: fetched.error instanceof Error ? fetched.error.message : String(fetched.error)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const { response } = fetched;
|
|
197
|
+
const body = responseBody(response);
|
|
198
|
+
if (response.status >= 300 && response.status < 400) {
|
|
199
|
+
const location = response.headers.get("location");
|
|
200
|
+
await cancelBody(body, "redirect response handled by sitemap reader");
|
|
201
|
+
if (!location) {
|
|
202
|
+
return {
|
|
203
|
+
_tag: "http_error",
|
|
204
|
+
url: request.url,
|
|
205
|
+
status: response.status,
|
|
206
|
+
statusText: "Redirect response is missing Location"
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
_tag: "redirect",
|
|
211
|
+
url: request.url,
|
|
212
|
+
location,
|
|
213
|
+
status: response.status
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (response.status === 404 || response.status === 410) {
|
|
217
|
+
await cancelBody(body, "not found response body is unused");
|
|
218
|
+
return {
|
|
219
|
+
_tag: "not_found",
|
|
220
|
+
url: request.url,
|
|
221
|
+
status: response.status
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
if (!response.ok) {
|
|
225
|
+
await cancelBody(body, "error response body is unused");
|
|
226
|
+
return {
|
|
227
|
+
_tag: "http_error",
|
|
228
|
+
url: request.url,
|
|
229
|
+
status: response.status,
|
|
230
|
+
statusText: response.statusText
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
const maxWireBytes = request.maxWireBytes ?? SITEMAP_READER_LIMITS.maxWireBytes;
|
|
234
|
+
const read = await readBoundedBody(body, maxWireBytes).then((result) => ({
|
|
235
|
+
_tag: "ok",
|
|
236
|
+
result
|
|
237
|
+
})).catch((error) => ({
|
|
238
|
+
_tag: "error",
|
|
239
|
+
error
|
|
240
|
+
}));
|
|
241
|
+
if (read._tag === "error") {
|
|
242
|
+
return {
|
|
243
|
+
_tag: "load_error",
|
|
244
|
+
url: request.url,
|
|
245
|
+
code: "network",
|
|
246
|
+
detail: read.error instanceof Error ? read.error.message : String(read.error)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (read.result._tag === "limit") {
|
|
250
|
+
return {
|
|
251
|
+
_tag: "load_error",
|
|
252
|
+
url: request.url,
|
|
253
|
+
code: "wire_limit",
|
|
254
|
+
detail: `Sitemap response exceeds ${maxWireBytes} wire bytes`,
|
|
255
|
+
bytesRead: read.result.bytesRead
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const sourceBody = stripIndexedSitemapLastmods(read.result.body);
|
|
259
|
+
loadedBodies.set(request.url, sourceBody);
|
|
260
|
+
return {
|
|
261
|
+
_tag: "body",
|
|
262
|
+
url: request.url,
|
|
263
|
+
body: sourceBody
|
|
264
|
+
};
|
|
265
|
+
};
|
|
233
266
|
}
|
|
234
267
|
async function recoverFailedUrlset(body) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
268
|
+
const entries = [];
|
|
269
|
+
let kind;
|
|
270
|
+
let failureReason;
|
|
271
|
+
for await (const event of parseSitemap(body, {
|
|
272
|
+
maxDecodedBytes: SITEMAP_READER_LIMITS.maxDecodedBytes,
|
|
273
|
+
maxEntries: SITEMAP_READER_LIMITS.maxEntries
|
|
274
|
+
})) {
|
|
275
|
+
if (event._tag === "document") kind = event.kind;
|
|
276
|
+
else if (event._tag === "url") entries.push(event.entry);
|
|
277
|
+
else if (event._tag === "end" && event.completeness._tag === "failed") failureReason = event.completeness.reason;
|
|
278
|
+
}
|
|
279
|
+
if (kind !== "urlset" || !failureReason) return { _tag: "none" };
|
|
280
|
+
return {
|
|
281
|
+
_tag: "failed",
|
|
282
|
+
entries,
|
|
283
|
+
reason: failureReason
|
|
284
|
+
};
|
|
252
285
|
}
|
|
253
286
|
function formatWalkFailure(failure) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return `${failure.url}: ${failure.result.reason}: ${failure.result.detail}`;
|
|
287
|
+
if (failure.result._tag === "not_found") return `${failure.url}: HTTP ${failure.result.status}`;
|
|
288
|
+
return `${failure.url}: ${failure.result.reason}: ${failure.result.detail}`;
|
|
257
289
|
}
|
|
258
290
|
function toWalkEntry(failure) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
291
|
+
if (failure.source === "root") {
|
|
292
|
+
return {
|
|
293
|
+
url: failure.url,
|
|
294
|
+
depth: 0,
|
|
295
|
+
source: "root"
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
url: failure.url,
|
|
300
|
+
depth: failure.depth,
|
|
301
|
+
source: "index_child",
|
|
302
|
+
parentUrl: failure.parentUrl
|
|
303
|
+
};
|
|
272
304
|
}
|
|
273
305
|
function isRetryableWalkFailure(failure) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return true;
|
|
278
|
-
return failure.result.reason === "load" && (failure.result.code === "network" || failure.result.code === "timeout" || failure.result.code === "cancelled");
|
|
306
|
+
if (failure.result._tag === "not_found") return true;
|
|
307
|
+
if (failure.result.reason === "http") return true;
|
|
308
|
+
return failure.result.reason === "load" && (failure.result.code === "network" || failure.result.code === "timeout" || failure.result.code === "cancelled");
|
|
279
309
|
}
|
|
280
310
|
function createNextFrontier(failures, frontier, seenDocuments) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return false;
|
|
289
|
-
seenEntries.add(entry.url);
|
|
290
|
-
return true;
|
|
291
|
-
});
|
|
311
|
+
const seenEntries = new Set();
|
|
312
|
+
const entries = [...failures.filter(isRetryableWalkFailure).map(toWalkEntry), ...frontier];
|
|
313
|
+
return entries.filter((entry) => {
|
|
314
|
+
if (seenDocuments.has(entry.url) || seenEntries.has(entry.url)) return false;
|
|
315
|
+
seenEntries.add(entry.url);
|
|
316
|
+
return true;
|
|
317
|
+
});
|
|
292
318
|
}
|
|
293
319
|
function isTerminalPartialReason(reason) {
|
|
294
|
-
|
|
320
|
+
return reason === "depth_limit" || reason === "url_limit" || reason === "document_partial";
|
|
295
321
|
}
|
|
296
322
|
function formatWalkError(result, parseFailures) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return `sitemap walk partial (${result.reasons.join(", ")}${details})`;
|
|
323
|
+
if (result.failures.length === 1 && parseFailures.length === 1 && result.reasons.length === 1 && result.reasons[0] === "read_failure") return `Sitemap parse failed: ${parseFailures[0]}`;
|
|
324
|
+
const failures = result.failures.map(formatWalkFailure);
|
|
325
|
+
const details = failures.length > 0 ? `; ${failures.join("; ")}` : "";
|
|
326
|
+
return `sitemap walk partial (${result.reasons.join(", ")}${details})`;
|
|
302
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Execute one bounded sitemap traversal round. Partial results include the
|
|
330
|
+
* exact pending frontier and committed document set needed by the next round.
|
|
331
|
+
*/
|
|
303
332
|
export async function crawlSitemapByRoute(event, input) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
333
|
+
const { route, state = null } = input;
|
|
334
|
+
const previousDocumentsAttempted = state?.documentsAttempted ?? 0;
|
|
335
|
+
const previousUrlsObserved = state?.urlsObserved ?? 0;
|
|
336
|
+
const previousRounds = state?.rounds ?? 0;
|
|
337
|
+
const startedAt = state?.startedAt ?? Date.now();
|
|
338
|
+
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
339
|
+
const usePublicAsset = config.sitemapPrerendered && hasAssets(event);
|
|
340
|
+
const configuredSiteUrl = createUniversalContext(event).siteUrl ?? SITEMAP_FALLBACK_ORIGIN;
|
|
341
|
+
const siteUrl = parseAbsoluteUrl(configuredSiteUrl);
|
|
342
|
+
// Development sitemaps use the local server origin, including their chunk links.
|
|
343
|
+
const requestOrigin = import.meta.dev && event ? getRequestURL(event, {
|
|
344
|
+
xForwardedHost: true,
|
|
345
|
+
xForwardedProto: true
|
|
346
|
+
}).origin : undefined;
|
|
347
|
+
if (siteUrl._tag === "error") {
|
|
348
|
+
return {
|
|
349
|
+
_tag: "failed",
|
|
350
|
+
urls: [],
|
|
351
|
+
documentsAttempted: previousDocumentsAttempted,
|
|
352
|
+
urlsObserved: previousUrlsObserved,
|
|
353
|
+
startedAt,
|
|
354
|
+
error: `Invalid site URL: ${configuredSiteUrl}`
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const rootUrl = parseAbsoluteUrl(route, `${siteUrl.value.origin}/`);
|
|
358
|
+
if (rootUrl._tag === "error") {
|
|
359
|
+
return {
|
|
360
|
+
_tag: "failed",
|
|
361
|
+
urls: [],
|
|
362
|
+
documentsAttempted: previousDocumentsAttempted,
|
|
363
|
+
urlsObserved: previousUrlsObserved,
|
|
364
|
+
startedAt,
|
|
365
|
+
error: `Invalid sitemap route: ${route}`
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const remainingUrls = SITEMAP_READER_LIMITS.maxUrls - previousUrlsObserved;
|
|
369
|
+
if (remainingUrls <= 0) {
|
|
370
|
+
return {
|
|
371
|
+
_tag: "failed",
|
|
372
|
+
urls: [],
|
|
373
|
+
documentsAttempted: previousDocumentsAttempted,
|
|
374
|
+
urlsObserved: previousUrlsObserved,
|
|
375
|
+
startedAt,
|
|
376
|
+
error: `sitemap walk partial (url_limit)`
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
const loadedBodies = new Map();
|
|
380
|
+
const seenDocuments = new Set(state?.seenDocuments ?? []);
|
|
381
|
+
const reader = createSitemapReader({
|
|
382
|
+
limits: SITEMAP_READER_LIMITS,
|
|
383
|
+
loadDocument: createLocalSitemapLoader(event, usePublicAsset, loadedBodies),
|
|
384
|
+
authorizeTarget: (request) => {
|
|
385
|
+
const target = parseAbsoluteUrl(request.url);
|
|
386
|
+
if (target._tag === "error") return {
|
|
387
|
+
_tag: "deny",
|
|
388
|
+
reason: `Invalid sitemap target: ${request.url}`
|
|
389
|
+
};
|
|
390
|
+
if (target.value.origin !== siteUrl.value.origin && target.value.origin !== requestOrigin) {
|
|
391
|
+
return {
|
|
392
|
+
_tag: "deny",
|
|
393
|
+
reason: `Sitemap target origin ${target.value.origin} differs from ${siteUrl.value.origin}`
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return { _tag: "allow" };
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
const result = await reader.walk(state?.frontier ?? rootUrl.value.toString(), {
|
|
400
|
+
...SITEMAP_READER_LIMITS,
|
|
401
|
+
maxUrls: remainingUrls,
|
|
402
|
+
seenDocuments: state?.seenDocuments,
|
|
403
|
+
onDocument: (document) => {
|
|
404
|
+
seenDocuments.add(document.requestedUrl);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
const documentsAttempted = previousDocumentsAttempted + result.documentsAttempted;
|
|
408
|
+
const urlsObserved = previousUrlsObserved + result.urlsObserved;
|
|
409
|
+
const entries = [...result.entries];
|
|
410
|
+
const parseFailures = [];
|
|
411
|
+
for (const failure of result.failures) {
|
|
412
|
+
if (failure.result._tag !== "failure" || failure.result.reason !== "document") continue;
|
|
413
|
+
const body = loadedBodies.get(failure.result.url);
|
|
414
|
+
if (!body) continue;
|
|
415
|
+
const recovered = await recoverFailedUrlset(body);
|
|
416
|
+
if (recovered._tag === "none") continue;
|
|
417
|
+
entries.push(...recovered.entries);
|
|
418
|
+
parseFailures.push(recovered.reason);
|
|
419
|
+
}
|
|
420
|
+
const seenUrls = new Set();
|
|
421
|
+
const urls = entries.filter((entry) => {
|
|
422
|
+
if (seenUrls.has(entry.loc)) return false;
|
|
423
|
+
seenUrls.add(entry.loc);
|
|
424
|
+
return true;
|
|
425
|
+
}).slice(0, remainingUrls).map(normalizeUrl);
|
|
426
|
+
logger.debug(`[sitemap] Found ${urls.length} URLs from ${rootUrl.value.pathname}${rootUrl.value.search}`);
|
|
427
|
+
if (result._tag === "complete") {
|
|
428
|
+
return {
|
|
429
|
+
_tag: "complete",
|
|
430
|
+
urls,
|
|
431
|
+
documentsAttempted,
|
|
432
|
+
urlsObserved,
|
|
433
|
+
startedAt
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
const error = formatWalkError(result, parseFailures);
|
|
437
|
+
const frontier = createNextFrontier(result.failures, result.frontier, seenDocuments);
|
|
438
|
+
const rounds = previousRounds + 1;
|
|
439
|
+
const canContinue = frontier.length > 0 && rounds < MAX_SITEMAP_CRAWL_ROUNDS && !result.reasons.some(isTerminalPartialReason);
|
|
440
|
+
logger.warn(`[sitemap] ${error}`);
|
|
441
|
+
if (!canContinue) {
|
|
442
|
+
return {
|
|
443
|
+
_tag: "failed",
|
|
444
|
+
urls,
|
|
445
|
+
documentsAttempted,
|
|
446
|
+
urlsObserved,
|
|
447
|
+
startedAt,
|
|
448
|
+
error
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
_tag: "partial",
|
|
453
|
+
urls,
|
|
454
|
+
documentsAttempted,
|
|
455
|
+
urlsObserved,
|
|
456
|
+
startedAt,
|
|
457
|
+
error,
|
|
458
|
+
state: {
|
|
459
|
+
_tag: "continuation",
|
|
460
|
+
frontier,
|
|
461
|
+
seenDocuments: [...seenDocuments],
|
|
462
|
+
documentsAttempted,
|
|
463
|
+
urlsObserved,
|
|
464
|
+
rounds,
|
|
465
|
+
startedAt
|
|
466
|
+
}
|
|
467
|
+
};
|
|
437
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Fetch and parse a single sitemap by route
|
|
471
|
+
* Supports both request context (event.fetch) and cron context (ASSETS.fetch or globalThis.$fetch)
|
|
472
|
+
*/
|
|
438
473
|
export async function fetchSitemapByRoute(event, route) {
|
|
439
|
-
|
|
440
|
-
|
|
474
|
+
const result = await crawlSitemapByRoute(event, { route });
|
|
475
|
+
return result._tag === "complete" ? { urls: result.urls } : {
|
|
476
|
+
urls: result.urls,
|
|
477
|
+
error: result.error
|
|
478
|
+
};
|
|
441
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Fetch all URLs from all sitemaps (or single sitemap if not multi-sitemap)
|
|
482
|
+
* Used for backwards compatibility and llms.txt generation
|
|
483
|
+
*/
|
|
442
484
|
export async function fetchSitemapUrlGroups(event, names) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
485
|
+
const sitemaps = getSitemapsFromConfig(event);
|
|
486
|
+
const groups = new Map();
|
|
487
|
+
// Multi-sitemap: fetch from each configured sitemap
|
|
488
|
+
if (sitemaps.length > 0) {
|
|
489
|
+
logger.debug(`[sitemap] Multi-sitemap mode: ${sitemaps.length} sitemaps`);
|
|
490
|
+
for (const sitemap of sitemaps) {
|
|
491
|
+
if (names !== undefined && !names.includes(sitemap.name)) continue;
|
|
492
|
+
// Include whatever URLs we got even on a partial failure: for llms.txt a
|
|
493
|
+
// partial page list beats none. The error is already logged downstream and
|
|
494
|
+
// matters to the cron crawl-status path, not to URL aggregation here.
|
|
495
|
+
const { urls } = await fetchSitemapByRoute(event, sitemap.route);
|
|
496
|
+
groups.set(sitemap.name, [...groups.get(sitemap.name) || [], ...urls]);
|
|
497
|
+
}
|
|
498
|
+
return groups;
|
|
499
|
+
}
|
|
500
|
+
if (names !== undefined && !names.includes("sitemap")) return groups;
|
|
501
|
+
// Single sitemap fallback: fetch /sitemap.xml
|
|
502
|
+
logger.debug(`[sitemap] Single sitemap mode: /sitemap.xml`);
|
|
503
|
+
const { urls, error } = await fetchSitemapByRoute(event, "/sitemap.xml");
|
|
504
|
+
if (error) {
|
|
505
|
+
logger.warn("Sitemap not found at /sitemap.xml - ensure @nuxtjs/sitemap is installed and configured");
|
|
506
|
+
} else if (urls.length === 0) {
|
|
507
|
+
logger.warn("Sitemap is empty - add routes to sitemap or configure sitemap.sources in nuxt.config");
|
|
508
|
+
}
|
|
509
|
+
groups.set("sitemap", urls);
|
|
510
|
+
return groups;
|
|
466
511
|
}
|
|
467
512
|
export async function fetchSitemapUrls(event) {
|
|
468
|
-
|
|
513
|
+
return [...(await fetchSitemapUrlGroups(event)).values()].flat();
|
|
469
514
|
}
|