nuxt-ai-ready 3.6.0 → 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 +20 -24
- 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
|
@@ -2,62 +2,80 @@ import { withBase } from "ufo";
|
|
|
2
2
|
import { localFetch, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY } from "../db/context.js";
|
|
4
4
|
const FETCH_TIMEOUT = 5e3;
|
|
5
|
-
const RETRY_STATUSES =
|
|
5
|
+
const RETRY_STATUSES = new Set([
|
|
6
|
+
408,
|
|
7
|
+
409,
|
|
8
|
+
425,
|
|
9
|
+
429,
|
|
10
|
+
500,
|
|
11
|
+
502,
|
|
12
|
+
503,
|
|
13
|
+
504
|
|
14
|
+
]);
|
|
6
15
|
function unavailablePublicAsset(_error) {
|
|
7
|
-
|
|
16
|
+
// Missing assets and self-fetch failures are expected here. Callers turn null
|
|
17
|
+
// into a domain-specific skip, warning, or retry.
|
|
18
|
+
return null;
|
|
8
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Get Cloudflare environment from event context or globalThis.__env__ (for scheduled tasks)
|
|
22
|
+
*/
|
|
9
23
|
export function getCfEnv(event) {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
const cloudflare = event?.context.cloudflare;
|
|
25
|
+
return cloudflare?.env ?? globalThis.__env__;
|
|
12
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if Cloudflare ASSETS binding is available
|
|
29
|
+
*/
|
|
13
30
|
export function hasAssets(event) {
|
|
14
|
-
|
|
31
|
+
return !!getCfEnv(event)?.ASSETS?.fetch;
|
|
15
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Fetch a public asset, preferring Cloudflare ASSETS binding when available.
|
|
35
|
+
* Falls back to Nitro localFetch with a timeout for unavailable assets.
|
|
36
|
+
*/
|
|
16
37
|
export async function fetchPublicAsset(event, path, options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
return null;
|
|
62
|
-
})().finally(() => clearTimeout(timeout));
|
|
38
|
+
const responseType = options?.responseType ?? "json";
|
|
39
|
+
const cfEnv = getCfEnv(event);
|
|
40
|
+
// Try Cloudflare ASSETS binding first
|
|
41
|
+
if (cfEnv?.ASSETS?.fetch) {
|
|
42
|
+
const response = await cfEnv.ASSETS.fetch(new Request(`https://assets.local${path}`)).catch(unavailablePublicAsset);
|
|
43
|
+
if (response?.ok) {
|
|
44
|
+
if (responseType === "json") return response.json().catch(unavailablePublicAsset);
|
|
45
|
+
if (responseType === "text") return response.text().catch(unavailablePublicAsset);
|
|
46
|
+
if (responseType === "arrayBuffer") return response.arrayBuffer().catch(unavailablePublicAsset);
|
|
47
|
+
if (responseType === "stream") return response.body;
|
|
48
|
+
}
|
|
49
|
+
// ASSETS exists but file not found - don't fall back
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
// Bound internal requests when the deployment has no ASSETS binding.
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
|
|
55
|
+
const assetContext = event && Object.fromEntries(Object.entries(event.context).filter(([key]) => ![
|
|
56
|
+
DB_CONTEXT_KEY,
|
|
57
|
+
DB_PROMISE_CONTEXT_KEY,
|
|
58
|
+
DB_WORK_CONTEXT_KEY
|
|
59
|
+
].includes(key)));
|
|
60
|
+
// A self-fetch outside the app base URL gets a redirect page, not the asset.
|
|
61
|
+
return (async () => {
|
|
62
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
63
|
+
// A nested response owns its cleanup. Preserve bindings, but keep the
|
|
64
|
+
// parent request's database resources out of the nested context.
|
|
65
|
+
const response = await localFetch(withBase(path, useRuntimeConfig().app.baseURL), { signal: controller.signal }, assetContext).catch(unavailablePublicAsset);
|
|
66
|
+
if (attempt === 0 && !controller.signal.aborted && (!response || RETRY_STATUSES.has(response.status))) {
|
|
67
|
+
await response?.body?.cancel().catch(unavailablePublicAsset);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!response?.ok) {
|
|
71
|
+
await response?.body?.cancel().catch(unavailablePublicAsset);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (responseType === "stream") return response.body;
|
|
75
|
+
if (responseType === "text") return response.text().catch(unavailablePublicAsset);
|
|
76
|
+
if (responseType === "arrayBuffer") return response.arrayBuffer().catch(unavailablePublicAsset);
|
|
77
|
+
return response.json().catch(unavailablePublicAsset);
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
})().finally(() => clearTimeout(timeout));
|
|
63
81
|
}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
export function getContentNegotiationVary(botNegotiation = false) {
|
|
2
|
-
|
|
2
|
+
return botNegotiation ? "Accept, Sec-Fetch-Dest, User-Agent" : "Accept";
|
|
3
3
|
}
|
|
4
4
|
function cachesWithoutNegotiationVariation(cache, botNegotiation) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
const varies = new Set(cache.varies?.map((header) => header.toLowerCase()));
|
|
12
|
-
return getContentNegotiationVary(botNegotiation).split(",").some((header) => !varies.has(header.trim().toLowerCase()));
|
|
5
|
+
if (!cache) return false;
|
|
6
|
+
if (typeof cache !== "object") return true;
|
|
7
|
+
if (cache.headersOnly) return false;
|
|
8
|
+
const varies = new Set(cache.varies?.map((header) => header.toLowerCase()));
|
|
9
|
+
return getContentNegotiationVary(botNegotiation).split(",").some((header) => !varies.has(header.trim().toLowerCase()));
|
|
13
10
|
}
|
|
14
11
|
export function resolveContentNegotiation(input) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
if (input.policy === "enabled") {
|
|
13
|
+
return {
|
|
14
|
+
_tag: "enabled",
|
|
15
|
+
source: "explicit",
|
|
16
|
+
vary: getContentNegotiationVary(input.botNegotiation)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (input.policy === "disabled") return {
|
|
20
|
+
_tag: "disabled",
|
|
21
|
+
source: "explicit"
|
|
22
|
+
};
|
|
23
|
+
if (input.routeRule.isr) return {
|
|
24
|
+
_tag: "disabled",
|
|
25
|
+
source: "isr"
|
|
26
|
+
};
|
|
27
|
+
if (cachesWithoutNegotiationVariation(input.routeRule.cache, input.botNegotiation === true)) return {
|
|
28
|
+
_tag: "disabled",
|
|
29
|
+
source: "route-cache"
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
_tag: "enabled",
|
|
33
|
+
source: "default",
|
|
34
|
+
vary: getContentNegotiationVary(input.botNegotiation)
|
|
35
|
+
};
|
|
24
36
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { lookupContentPage } from "#ai-ready-virtual/content-lookup.mjs";
|
|
2
|
+
// Look up a route in @nuxt/content's page collections and return the source
|
|
3
|
+
// markdown (AST → minimark stringify). Returns null when content isn't
|
|
4
|
+
// installed, or when no page collection contains the path.
|
|
2
5
|
export async function tryGetContentMarkdown(event, path) {
|
|
3
|
-
|
|
6
|
+
return lookupContentPage(event, path);
|
|
4
7
|
}
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { createSiteConfigStack } from "site-config-stack";
|
|
2
2
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
|
+
/**
|
|
4
|
+
* Create context that works in both request and scheduled task contexts
|
|
5
|
+
* In request context: uses H3Event and nuxt-site-config middleware
|
|
6
|
+
* In scheduled task: rebuilds from build-time site-config stack
|
|
7
|
+
*/
|
|
3
8
|
export function createUniversalContext(event) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const runtimeConfig = useRuntimeConfig();
|
|
10
|
+
// Try request-time site config first (set by nuxt-site-config middleware)
|
|
11
|
+
let siteUrl = runtimeConfig.site?.url || (runtimeConfig.public?.site)?.url;
|
|
12
|
+
// Fallback: rebuild from nuxt-site-config's build-time stack
|
|
13
|
+
// Works in scheduled tasks where middleware hasn't run
|
|
14
|
+
if (!siteUrl) {
|
|
15
|
+
const siteConfigRuntime = runtimeConfig["nuxt-site-config"];
|
|
16
|
+
if (siteConfigRuntime?.stack) {
|
|
17
|
+
const stack = createSiteConfigStack();
|
|
18
|
+
siteConfigRuntime.stack.forEach((c) => stack.push(c));
|
|
19
|
+
siteUrl = stack.get().url;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
siteUrl,
|
|
24
|
+
hasEvent: !!event
|
|
25
|
+
};
|
|
18
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Get site URL from context, throwing if not configured
|
|
29
|
+
*/
|
|
19
30
|
export function requireSiteUrl(event) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
const ctx = createUniversalContext(event);
|
|
32
|
+
if (!ctx.siteUrl) {
|
|
33
|
+
throw new Error("Site URL not configured. Set site.url in nuxt.config.");
|
|
34
|
+
}
|
|
35
|
+
return ctx.siteUrl;
|
|
25
36
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export function resolveSitemapIntervalMinutes(runtimeSyncTtlSeconds) {
|
|
2
|
-
|
|
2
|
+
return Math.max(1, Math.ceil(runtimeSyncTtlSeconds / 60));
|
|
3
3
|
}
|
|
4
4
|
export function resolveCronPlan(input) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const { status, staleCheckNeeded } = input;
|
|
6
|
+
return {
|
|
7
|
+
sitemapIntervalMinutes: resolveSitemapIntervalMinutes(input.runtimeSyncTtlSeconds),
|
|
8
|
+
hasWork: staleCheckNeeded || status.pendingPages > 0 || status.sitemapsNeedCrawl > 0
|
|
9
|
+
};
|
|
10
10
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export const AI_CATALOG_MEDIA_TYPE = "application/ai-catalog+json";
|
|
2
2
|
export const MCP_SERVER_CARD_MEDIA_TYPE = "application/mcp-server-card+json";
|
|
3
3
|
export function matchesDiscoveryEtag(requestHeader, etag) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
4
|
+
if (!requestHeader) return false;
|
|
5
|
+
return requestHeader.split(",").some((candidate) => {
|
|
6
|
+
const normalized = candidate.trim().replace(/^W\//, "");
|
|
7
|
+
return normalized === "*" || normalized === etag;
|
|
8
|
+
});
|
|
10
9
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetchRawWithEvent as fetchSharedRawWithEvent } from "#nuxtseo/nitro";
|
|
2
|
+
/** Preserve request context while using Nitro's in-process dispatcher on both majors. */
|
|
2
3
|
export function fetchRawWithEvent(event, request, init) {
|
|
3
|
-
|
|
4
|
+
return fetchSharedRawWithEvent(event, request, init);
|
|
4
5
|
}
|
|
@@ -1,67 +1,54 @@
|
|
|
1
|
+
// Standalone YAML frontmatter builder for cases where there is no HTML to feed
|
|
2
|
+
// through mdream (e.g. the friendly 404 markdown response). For HTML-derived
|
|
3
|
+
// pages, prefer mdream's `additionalFields` so the engine owns emission.
|
|
1
4
|
import { isMap, isScalar, parseDocument } from "yaml";
|
|
2
5
|
function escapeYamlString(value) {
|
|
3
|
-
|
|
6
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
4
7
|
}
|
|
5
8
|
export function buildFrontmatter(fields) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
lines.push("alternates:");
|
|
19
|
-
for (const alt of fields.alternates)
|
|
20
|
-
lines.push(` - { hreflang: "${escapeYamlString(alt.hreflang)}", href: "${escapeYamlString(alt.href)}" }`);
|
|
21
|
-
}
|
|
22
|
-
lines.push("---", "");
|
|
23
|
-
return lines.join("\n");
|
|
9
|
+
const lines = ["---"];
|
|
10
|
+
if (fields.title) lines.push(`title: "${escapeYamlString(fields.title)}"`);
|
|
11
|
+
if (fields.description) lines.push(`description: "${escapeYamlString(fields.description)}"`);
|
|
12
|
+
if (fields.canonical_url) lines.push(`canonical_url: "${escapeYamlString(fields.canonical_url)}"`);
|
|
13
|
+
if (fields.last_updated) lines.push(`last_updated: "${escapeYamlString(fields.last_updated)}"`);
|
|
14
|
+
if (fields.locale) lines.push(`locale: "${escapeYamlString(fields.locale)}"`);
|
|
15
|
+
if (fields.alternates?.length) {
|
|
16
|
+
lines.push("alternates:");
|
|
17
|
+
for (const alt of fields.alternates) lines.push(` - { hreflang: "${escapeYamlString(alt.hreflang)}", href: "${escapeYamlString(alt.href)}" }`);
|
|
18
|
+
}
|
|
19
|
+
lines.push("---", "");
|
|
20
|
+
return lines.join("\n");
|
|
24
21
|
}
|
|
25
22
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
|
|
26
23
|
export function layerFrontmatter(fields, markdown) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
${markdown}`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (value !== void 0 && value !== "")
|
|
37
|
-
document.set(key, value);
|
|
38
|
-
}
|
|
39
|
-
const body = markdown.slice(match[0].length).replace(/^\r?\n/, "");
|
|
40
|
-
return `---
|
|
41
|
-
${document.toString({ lineWidth: 0 }).trimEnd()}
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
${body}`;
|
|
24
|
+
const match = markdown.match(FRONTMATTER_RE);
|
|
25
|
+
if (!match) return `${buildFrontmatter(fields)}\n${markdown}`;
|
|
26
|
+
const document = parseDocument(match[1]);
|
|
27
|
+
if (document.errors.length || !isMap(document.contents)) return `${buildFrontmatter(fields)}\n${markdown}`;
|
|
28
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
29
|
+
if (value !== undefined && value !== "") document.set(key, value);
|
|
30
|
+
}
|
|
31
|
+
const body = markdown.slice(match[0].length).replace(/^\r?\n/, "");
|
|
32
|
+
return `---\n${document.toString({ lineWidth: 0 }).trimEnd()}\n---\n\n${body}`;
|
|
45
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Move mdream's `meta.description` to a root `description` field, the shape
|
|
36
|
+
* Content source pages and hand-built frontmatter already use. Other `meta`
|
|
37
|
+
* fields stay where mdream put them.
|
|
38
|
+
*/
|
|
46
39
|
export function hoistMetaDescription(markdown) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
root.items.splice(titleIndex + 1, 0, document.createPair("description", description));
|
|
62
|
-
}
|
|
63
|
-
return `---
|
|
64
|
-
${document.toString({ lineWidth: 0 }).trimEnd()}
|
|
65
|
-
---
|
|
66
|
-
${markdown.slice(match[0].length)}`;
|
|
40
|
+
const match = markdown.match(FRONTMATTER_RE);
|
|
41
|
+
if (!match) return markdown;
|
|
42
|
+
const document = parseDocument(match[1]);
|
|
43
|
+
const root = document.contents;
|
|
44
|
+
const meta = document.get("meta");
|
|
45
|
+
if (document.errors.length || !isMap(root) || !isMap(meta) || !meta.has("description")) return markdown;
|
|
46
|
+
const description = meta.get("description", true);
|
|
47
|
+
meta.delete("description");
|
|
48
|
+
if (!meta.items.length) document.delete("meta");
|
|
49
|
+
if (!document.has("description")) {
|
|
50
|
+
const titleIndex = root.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === "title");
|
|
51
|
+
root.items.splice(titleIndex + 1, 0, document.createPair("description", description));
|
|
52
|
+
}
|
|
53
|
+
return `---\n${document.toString({ lineWidth: 0 }).trimEnd()}\n---\n${markdown.slice(match[0].length)}`;
|
|
67
54
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
localePath,
|
|
4
|
-
resolveI18nDomain,
|
|
5
|
-
resolveLocaleAlternates,
|
|
6
|
-
resolveLocaleFromRoute
|
|
7
|
-
} from "#ai-ready-virtual/i18n-runtime.mjs";
|
|
1
|
+
export { computeLocaleAlternates, localePath, resolveI18nDomain, resolveLocaleAlternates, resolveLocaleFromRoute } from "#ai-ready-virtual/i18n-runtime.mjs";
|
|
2
|
+
/** Get the runtime i18n config from runtimeConfig, or null when disabled. */
|
|
8
3
|
export function getRuntimeI18n(aiReadyConfig) {
|
|
9
|
-
|
|
4
|
+
return aiReadyConfig.i18n || null;
|
|
10
5
|
}
|