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.
Files changed (161) hide show
  1. package/dist/agent-skills-config-CmZq9uWW.mjs +18 -0
  2. package/dist/agent-skills-zGLgFB6H.mjs +468 -0
  3. package/dist/cli.d.mts +1 -0
  4. package/dist/cli.mjs +656 -570
  5. package/dist/devtools/pages/ai-ready/debug.vue +9 -3
  6. package/dist/devtools/pages/ai-ready/index.vue +3 -1
  7. package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
  8. package/dist/devtools/pages/ai-ready.vue +28 -4
  9. package/dist/module.d.mts +106 -112
  10. package/dist/module.json +3 -3
  11. package/dist/module.mjs +2732 -26
  12. package/dist/package-metadata-B1darl8W.mjs +28 -0
  13. package/dist/prerender-QMv07W4h.mjs +650 -0
  14. package/dist/runtime/app/composables/webmcp.js +90 -97
  15. package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
  16. package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
  17. package/dist/runtime/app/plugins/webmcp.client.js +49 -53
  18. package/dist/runtime/app/webmcp-config.js +2 -2
  19. package/dist/runtime/cache-control.js +16 -10
  20. package/dist/runtime/i18n-url.js +6 -6
  21. package/dist/runtime/index.js +4 -12
  22. package/dist/runtime/llms-txt-directive.js +20 -13
  23. package/dist/runtime/llms-txt-files.js +188 -187
  24. package/dist/runtime/llms-txt-format.js +54 -55
  25. package/dist/runtime/llms-txt-i18n.js +22 -19
  26. package/dist/runtime/llms-txt-utils.js +140 -95
  27. package/dist/runtime/markdown-links.js +45 -39
  28. package/dist/runtime/markdown-path.js +29 -9
  29. package/dist/runtime/markdown-text.js +2 -1
  30. package/dist/runtime/mcp.js +5 -1
  31. package/dist/runtime/route-path.js +14 -8
  32. package/dist/runtime/server/db/drizzle/client.js +71 -75
  33. package/dist/runtime/server/db/drizzle/index.js +16 -28
  34. package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
  35. package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
  36. package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
  37. package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
  38. package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
  39. package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
  40. package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
  41. package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
  42. package/dist/runtime/server/db/drizzle/queries.js +633 -532
  43. package/dist/runtime/server/db/drizzle/raw.js +200 -176
  44. package/dist/runtime/server/db/index.js +3 -0
  45. package/dist/runtime/server/db/queries.js +816 -607
  46. package/dist/runtime/server/db/schema/postgres.js +56 -50
  47. package/dist/runtime/server/db/schema/sqlite.js +56 -50
  48. package/dist/runtime/server/db/schema-sql.js +35 -38
  49. package/dist/runtime/server/db/seed.js +60 -45
  50. package/dist/runtime/server/db/shared.js +300 -213
  51. package/dist/runtime/server/index.js +1 -17
  52. package/dist/runtime/server/mcp/cache-key.js +5 -1
  53. package/dist/runtime/server/mcp/resources/pages.js +32 -33
  54. package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
  55. package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
  56. package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
  57. package/dist/runtime/server/middleware/markdown.d.ts +1 -1
  58. package/dist/runtime/server/middleware/markdown.js +15 -13
  59. package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
  60. package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
  61. package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
  62. package/dist/runtime/server/middleware/render-markdown.js +164 -144
  63. package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
  64. package/dist/runtime/server/plugins/ai-terms.js +4 -8
  65. package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
  66. package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
  67. package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
  68. package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
  69. package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
  70. package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
  71. package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
  72. package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
  73. package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
  74. package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
  75. package/dist/runtime/server/plugins/link-header.d.ts +1 -1
  76. package/dist/runtime/server/plugins/link-header.js +30 -30
  77. package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
  78. package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
  79. package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
  80. package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
  81. package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
  82. package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
  83. package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
  84. package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
  85. package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
  86. package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
  87. package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
  88. package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
  89. package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
  90. package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
  91. package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
  92. package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
  93. package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
  94. package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
  95. package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
  96. package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
  97. package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
  98. package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
  99. package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
  100. package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
  101. package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
  102. package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
  103. package/dist/runtime/server/routes/agent-skills-index.js +8 -6
  104. package/dist/runtime/server/routes/ai-catalog.js +19 -19
  105. package/dist/runtime/server/routes/ai-terms.js +23 -19
  106. package/dist/runtime/server/routes/api-catalog.js +23 -23
  107. package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
  108. package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
  109. package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
  110. package/dist/runtime/server/routes/llms.txt.get.js +38 -33
  111. package/dist/runtime/server/routes/mcp-server-card.js +19 -19
  112. package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
  113. package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
  114. package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
  115. package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
  116. package/dist/runtime/server/utils/auth.js +76 -53
  117. package/dist/runtime/server/utils/batchIndex.js +72 -60
  118. package/dist/runtime/server/utils/checkStale.js +181 -134
  119. package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
  120. package/dist/runtime/server/utils/cloudflare.js +69 -51
  121. package/dist/runtime/server/utils/content-negotiation.js +30 -18
  122. package/dist/runtime/server/utils/content.js +4 -1
  123. package/dist/runtime/server/utils/context.js +30 -19
  124. package/dist/runtime/server/utils/cron-plan.js +6 -6
  125. package/dist/runtime/server/utils/discovery-response.js +5 -6
  126. package/dist/runtime/server/utils/fetch.js +2 -1
  127. package/dist/runtime/server/utils/frontmatter.js +44 -57
  128. package/dist/runtime/server/utils/i18n.js +3 -8
  129. package/dist/runtime/server/utils/indexPage.js +152 -113
  130. package/dist/runtime/server/utils/keywords.js +278 -277
  131. package/dist/runtime/server/utils/link-header.js +67 -56
  132. package/dist/runtime/server/utils/llms-full.js +39 -49
  133. package/dist/runtime/server/utils/markdown-redirect.js +26 -14
  134. package/dist/runtime/server/utils/markdown-request.js +62 -47
  135. package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
  136. package/dist/runtime/server/utils/negotiation-decision.js +106 -34
  137. package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
  138. package/dist/runtime/server/utils/negotiation-response.js +195 -144
  139. package/dist/runtime/server/utils/page-updated-at.js +23 -15
  140. package/dist/runtime/server/utils/prerender-html.js +31 -17
  141. package/dist/runtime/server/utils/runCron.js +263 -192
  142. package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
  143. package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
  144. package/dist/runtime/server/utils/sitemap-md.js +39 -50
  145. package/dist/runtime/server/utils/sitemap-routes.js +7 -7
  146. package/dist/runtime/server/utils/sitemap.js +459 -414
  147. package/dist/runtime/server/utils.js +141 -122
  148. package/dist/runtime/site-tool-catalog.js +39 -43
  149. package/dist/runtime/site-tool-config.js +1 -0
  150. package/dist/runtime/sync-secret.js +11 -11
  151. package/dist/runtime/types.js +1 -0
  152. package/dist/runtime/webmcp-site-tools.js +278 -250
  153. package/dist/runtime/webmcp.js +53 -42
  154. package/dist/static-headers-G7hFL3wE.mjs +328 -0
  155. package/dist/types.d.mts +1 -9
  156. package/package.json +18 -22
  157. package/skills/nuxt-ai-ready/SKILL.md +8 -2
  158. package/dist/chunks/agent-skills.mjs +0 -383
  159. package/dist/chunks/prerender.mjs +0 -683
  160. package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
  161. 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 = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504]);
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
- return null;
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
- const cloudflare = event?.context.cloudflare;
11
- return cloudflare?.env ?? globalThis.__env__;
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
- return !!getCfEnv(event)?.ASSETS?.fetch;
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
- const responseType = options?.responseType ?? "json";
18
- const cfEnv = getCfEnv(event);
19
- if (cfEnv?.ASSETS?.fetch) {
20
- const response = await cfEnv.ASSETS.fetch(
21
- new Request(`https://assets.local${path}`)
22
- ).catch(unavailablePublicAsset);
23
- if (response?.ok) {
24
- if (responseType === "json")
25
- return response.json().catch(unavailablePublicAsset);
26
- if (responseType === "text")
27
- return response.text().catch(unavailablePublicAsset);
28
- if (responseType === "arrayBuffer")
29
- return response.arrayBuffer().catch(unavailablePublicAsset);
30
- if (responseType === "stream")
31
- return response.body;
32
- }
33
- return null;
34
- }
35
- const controller = new AbortController();
36
- const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
37
- const assetContext = event && Object.fromEntries(
38
- Object.entries(event.context).filter(([key]) => ![DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY].includes(key))
39
- );
40
- return (async () => {
41
- for (let attempt = 0; attempt < 2; attempt++) {
42
- const response = await localFetch(withBase(path, useRuntimeConfig().app.baseURL), {
43
- signal: controller.signal
44
- }, assetContext).catch(unavailablePublicAsset);
45
- if (attempt === 0 && !controller.signal.aborted && (!response || RETRY_STATUSES.has(response.status))) {
46
- await response?.body?.cancel().catch(unavailablePublicAsset);
47
- continue;
48
- }
49
- if (!response?.ok) {
50
- await response?.body?.cancel().catch(unavailablePublicAsset);
51
- return null;
52
- }
53
- if (responseType === "stream")
54
- return response.body;
55
- if (responseType === "text")
56
- return response.text().catch(unavailablePublicAsset);
57
- if (responseType === "arrayBuffer")
58
- return response.arrayBuffer().catch(unavailablePublicAsset);
59
- return response.json().catch(unavailablePublicAsset);
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
- return botNegotiation ? "Accept, Sec-Fetch-Dest, User-Agent" : "Accept";
2
+ return botNegotiation ? "Accept, Sec-Fetch-Dest, User-Agent" : "Accept";
3
3
  }
4
4
  function cachesWithoutNegotiationVariation(cache, botNegotiation) {
5
- if (!cache)
6
- return false;
7
- if (typeof cache !== "object")
8
- return true;
9
- if (cache.headersOnly)
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
- if (input.policy === "enabled")
16
- return { _tag: "enabled", source: "explicit", vary: getContentNegotiationVary(input.botNegotiation) };
17
- if (input.policy === "disabled")
18
- return { _tag: "disabled", source: "explicit" };
19
- if (input.routeRule.isr)
20
- return { _tag: "disabled", source: "isr" };
21
- if (cachesWithoutNegotiationVariation(input.routeRule.cache, input.botNegotiation === true))
22
- return { _tag: "disabled", source: "route-cache" };
23
- return { _tag: "enabled", source: "default", vary: getContentNegotiationVary(input.botNegotiation) };
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
- return lookupContentPage(event, path);
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
- const runtimeConfig = useRuntimeConfig();
5
- let siteUrl = runtimeConfig.site?.url || runtimeConfig.public?.site?.url;
6
- if (!siteUrl) {
7
- const siteConfigRuntime = runtimeConfig["nuxt-site-config"];
8
- if (siteConfigRuntime?.stack) {
9
- const stack = createSiteConfigStack();
10
- siteConfigRuntime.stack.forEach((c) => stack.push(c));
11
- siteUrl = stack.get().url;
12
- }
13
- }
14
- return {
15
- siteUrl,
16
- hasEvent: !!event
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
- const ctx = createUniversalContext(event);
21
- if (!ctx.siteUrl) {
22
- throw new Error("Site URL not configured. Set site.url in nuxt.config.");
23
- }
24
- return ctx.siteUrl;
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
- return Math.max(1, Math.ceil(runtimeSyncTtlSeconds / 60));
2
+ return Math.max(1, Math.ceil(runtimeSyncTtlSeconds / 60));
3
3
  }
4
4
  export function resolveCronPlan(input) {
5
- const { status, staleCheckNeeded } = input;
6
- return {
7
- sitemapIntervalMinutes: resolveSitemapIntervalMinutes(input.runtimeSyncTtlSeconds),
8
- hasWork: staleCheckNeeded || status.pendingPages > 0 || status.sitemapsNeedCrawl > 0
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
- if (!requestHeader)
5
- return false;
6
- return requestHeader.split(",").some((candidate) => {
7
- const normalized = candidate.trim().replace(/^W\//, "");
8
- return normalized === "*" || normalized === etag;
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
- return fetchSharedRawWithEvent(event, request, init);
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
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
6
+ return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
4
7
  }
5
8
  export function buildFrontmatter(fields) {
6
- const lines = ["---"];
7
- if (fields.title)
8
- lines.push(`title: "${escapeYamlString(fields.title)}"`);
9
- if (fields.description)
10
- lines.push(`description: "${escapeYamlString(fields.description)}"`);
11
- if (fields.canonical_url)
12
- lines.push(`canonical_url: "${escapeYamlString(fields.canonical_url)}"`);
13
- if (fields.last_updated)
14
- lines.push(`last_updated: "${escapeYamlString(fields.last_updated)}"`);
15
- if (fields.locale)
16
- lines.push(`locale: "${escapeYamlString(fields.locale)}"`);
17
- if (fields.alternates?.length) {
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
- const match = markdown.match(FRONTMATTER_RE);
28
- if (!match)
29
- return `${buildFrontmatter(fields)}
30
- ${markdown}`;
31
- const document = parseDocument(match[1]);
32
- if (document.errors.length || !isMap(document.contents))
33
- return `${buildFrontmatter(fields)}
34
- ${markdown}`;
35
- for (const [key, value] of Object.entries(fields)) {
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
- const match = markdown.match(FRONTMATTER_RE);
48
- if (!match)
49
- return markdown;
50
- const document = parseDocument(match[1]);
51
- const root = document.contents;
52
- const meta = document.get("meta");
53
- if (document.errors.length || !isMap(root) || !isMap(meta) || !meta.has("description"))
54
- return markdown;
55
- const description = meta.get("description", true);
56
- meta.delete("description");
57
- if (!meta.items.length)
58
- document.delete("meta");
59
- if (!document.has("description")) {
60
- const titleIndex = root.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === "title");
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
- computeLocaleAlternates,
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
- return aiReadyConfig.i18n || null;
4
+ return aiReadyConfig.i18n || null;
10
5
  }