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
|
@@ -14,150 +14,170 @@ import { INTERNAL_HEADER } from "../utils/negotiation-decision.js";
|
|
|
14
14
|
import { buildNegotiationContext, ensureSiteConfig, setMarkdownHeaders } from "../utils/negotiation-response.js";
|
|
15
15
|
import { appendSitemapSection, SITEMAP_MD_ROUTE } from "../utils/sitemap-md.js";
|
|
16
16
|
function notFoundMarkdown(ctx, canonicalUrl, build) {
|
|
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
|
-
${body}`;
|
|
17
|
+
const { path, config, resolveUrl, routeContext } = ctx;
|
|
18
|
+
const body = [
|
|
19
|
+
`# Page not found`,
|
|
20
|
+
``,
|
|
21
|
+
`No content is available at \`${path}\`.`,
|
|
22
|
+
``,
|
|
23
|
+
`Try one of these resources:`,
|
|
24
|
+
``,
|
|
25
|
+
`- [Sitemap](${resolveUrl("/sitemap.xml")})`,
|
|
26
|
+
`- [llms.txt](${resolveUrl("/llms.txt")})`,
|
|
27
|
+
...config.llmsFullTxt === false ? [] : [`- [llms-full.txt](${resolveUrl("/llms-full.txt")})`],
|
|
28
|
+
``
|
|
29
|
+
].join("\n");
|
|
30
|
+
const i18n = config.i18n;
|
|
31
|
+
const locale = i18n ? resolveLocaleFromRoute(path, i18n, routeContext).locale : undefined;
|
|
32
|
+
const alternates = i18n ? computeLocaleAlternates(path, i18n, routeContext).map((a) => ({
|
|
33
|
+
hreflang: a.hreflang,
|
|
34
|
+
href: resolveLocaleAlternateUrl(a, resolveUrl)
|
|
35
|
+
})) : undefined;
|
|
36
|
+
const frontmatter = build({
|
|
37
|
+
title: "Page not found",
|
|
38
|
+
description: `No content is available at ${path}.`,
|
|
39
|
+
canonical_url: canonicalUrl,
|
|
40
|
+
locale,
|
|
41
|
+
alternates
|
|
42
|
+
});
|
|
43
|
+
return `${frontmatter}\n${body}`;
|
|
45
44
|
}
|
|
46
45
|
export async function renderMarkdown(event, markdownPath) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
46
|
+
await ensureSiteConfig(event);
|
|
47
|
+
const ctx = buildNegotiationContext(event, markdownPath);
|
|
48
|
+
const { path, config, resolvePath, resolveUrl, routeContext } = ctx;
|
|
49
|
+
const canonicalUrl = resolveUrl(path);
|
|
50
|
+
// Source Markdown keeps its root-relative links. Read on its own, such a
|
|
51
|
+
// link has no page URL to resolve against, so every one gets the origin.
|
|
52
|
+
const finalizeMarkdown = (markdown) => {
|
|
53
|
+
const withSitemap = config.sitemapMd === false ? markdown : appendSitemapSection(markdown, resolvePath(SITEMAP_MD_ROUTE));
|
|
54
|
+
const llmsTxt = config.llmsTxt;
|
|
55
|
+
const withDirective = llmsTxt?.directive?.markdown === false ? withSitemap : insertLlmsTxtDirective(withSitemap, resolveUrl("/llms.txt"));
|
|
56
|
+
return absoluteMarkdownLinks(withDirective, canonicalUrl);
|
|
57
|
+
};
|
|
58
|
+
// A site that already holds the markdown a page was rendered from can serve
|
|
59
|
+
// it verbatim. That is better than converting the rendering back, and it
|
|
60
|
+
// skips the internal subrequest that fetches the HTML.
|
|
61
|
+
const sourceContext = {
|
|
62
|
+
route: path,
|
|
63
|
+
event,
|
|
64
|
+
source: null
|
|
65
|
+
};
|
|
66
|
+
await useNitroApp().hooks.callHook("ai-ready:markdown:source", sourceContext);
|
|
67
|
+
if (sourceContext.source) {
|
|
68
|
+
const { markdown, title, description, updatedAt } = sourceContext.source;
|
|
69
|
+
const responseMarkdown = layerFrontmatter({
|
|
70
|
+
title: title ?? path,
|
|
71
|
+
description,
|
|
72
|
+
canonical_url: canonicalUrl,
|
|
73
|
+
last_updated: updatedAt
|
|
74
|
+
}, markdown);
|
|
75
|
+
setMarkdownHeaders(event, ctx);
|
|
76
|
+
return finalizeMarkdown(responseMarkdown);
|
|
77
|
+
}
|
|
78
|
+
// Prefer @nuxt/content source over HTML→mdream conversion. Content stores
|
|
79
|
+
// pages as a structural AST (minimark) that round-trips to markdown without
|
|
80
|
+
// the lossiness of HTML parsing. Frontmatter is layered: our canonical_url +
|
|
81
|
+
// last_updated land at the top so Vercel's agent-readability audit picks
|
|
82
|
+
// them up, mirroring the HTML conversion path's behaviour.
|
|
83
|
+
const contentPage = await tryGetContentMarkdown(event, path).catch((e) => {
|
|
84
|
+
logger.debug(`[markdown] Content lookup failed for ${path}`, e);
|
|
85
|
+
return null;
|
|
86
|
+
});
|
|
87
|
+
if (contentPage) {
|
|
88
|
+
logger.debug(`[markdown] Serving content source for ${path} (${contentPage.markdown.length} bytes)`);
|
|
89
|
+
const frontmatter = buildFrontmatter({
|
|
90
|
+
title: contentPage.title,
|
|
91
|
+
description: contentPage.description,
|
|
92
|
+
canonical_url: canonicalUrl,
|
|
93
|
+
last_updated: contentPage.updatedAt
|
|
94
|
+
});
|
|
95
|
+
setMarkdownHeaders(event, ctx);
|
|
96
|
+
return finalizeMarkdown(`${frontmatter}\n${contentPage.markdown}`);
|
|
97
|
+
}
|
|
98
|
+
// Explicit .md: fetch HTML with internal marker to prevent recursion, convert
|
|
99
|
+
// via mdream. Manual redirect so an upstream redirect can point the client
|
|
100
|
+
// at the markdown sibling of its target.
|
|
101
|
+
const origin = getRequestURL(event).origin;
|
|
102
|
+
const siteUrl = resolveUrl("/");
|
|
103
|
+
const redirectOptions = {
|
|
104
|
+
pageUrl: `${origin}${resolvePath(path)}`,
|
|
105
|
+
origins: URL.canParse(siteUrl) ? [new URL(siteUrl).origin] : []
|
|
106
|
+
};
|
|
107
|
+
let htmlPath = resolvePath(path);
|
|
108
|
+
let response = null;
|
|
109
|
+
// Two fetches at most: a redirect back onto this same markdown document, such
|
|
110
|
+
// as a trailing-slash redirect, is followed once instead of looping.
|
|
111
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
112
|
+
logger.debug(`[markdown] Fetching HTML for ${htmlPath}`);
|
|
113
|
+
response = await fetchRawWithEvent(event, htmlPath, {
|
|
114
|
+
headers: { [INTERNAL_HEADER]: "1" },
|
|
115
|
+
redirect: "manual"
|
|
116
|
+
}).catch((e) => {
|
|
117
|
+
logger.error(`Failed to fetch HTML for ${htmlPath}`, e);
|
|
118
|
+
return null;
|
|
119
|
+
});
|
|
120
|
+
const location = response && response.status >= 300 && response.status < 400 ? response.headers.get("location") : null;
|
|
121
|
+
if (!response || !location) break;
|
|
122
|
+
const redirect = resolveMarkdownRedirect(location, redirectOptions);
|
|
123
|
+
if (redirect._tag === "follow" && attempt === 0) {
|
|
124
|
+
htmlPath = redirect.path;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
setHeader(event, "location", redirect._tag === "redirect" ? redirect.location : location);
|
|
128
|
+
return createError({
|
|
129
|
+
statusCode: response.status,
|
|
130
|
+
statusMessage: response.statusText
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (!response) {
|
|
134
|
+
throw createError({
|
|
135
|
+
statusCode: 502,
|
|
136
|
+
statusMessage: "Bad Gateway"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// Keep application errors intact, including their body and headers. Only a
|
|
140
|
+
// missing page gets the Markdown guidance response.
|
|
141
|
+
if (!response.ok && response.status !== 404) return response;
|
|
142
|
+
if (response.status === 404) {
|
|
143
|
+
setMarkdownHeaders(event, ctx, response.headers);
|
|
144
|
+
setResponseStatus(event, 404);
|
|
145
|
+
return notFoundMarkdown(ctx, canonicalUrl, buildFrontmatter);
|
|
146
|
+
}
|
|
147
|
+
const contentType = response.headers.get("content-type") || "";
|
|
148
|
+
if (!contentType.includes("text/html")) {
|
|
149
|
+
setMarkdownHeaders(event, ctx, response.headers);
|
|
150
|
+
setResponseStatus(event, 404);
|
|
151
|
+
return notFoundMarkdown(ctx, canonicalUrl, buildFrontmatter);
|
|
152
|
+
}
|
|
153
|
+
const html = await response.text();
|
|
154
|
+
logger.debug(`[markdown] Fetched HTML for ${path} (${html.length} bytes)`);
|
|
155
|
+
const { queryPages } = await import("../db/queries.js");
|
|
156
|
+
// Resolve last_updated: DB (authoritative, set at index time) → page meta tags.
|
|
157
|
+
// No source means no field: the request time would claim the page just changed.
|
|
158
|
+
const dbPage = await queryPages(event, { route: path }).catch((err) => {
|
|
159
|
+
logger.debug(`[markdown] DB lookup failed for ${path}:`, err);
|
|
160
|
+
return undefined;
|
|
161
|
+
});
|
|
162
|
+
const lastUpdated = dbPage?.updatedAt || extractLastUpdated(html);
|
|
163
|
+
// Convert via mdream; pass canonical_url + last_updated through additionalFields
|
|
164
|
+
// so they land at the root of mdream's emitted YAML frontmatter, where
|
|
165
|
+
// Vercel's agent-readability audit looks for them.
|
|
166
|
+
// Locale is a simple scalar; alternates are surfaced via the Link header
|
|
167
|
+
// (RFC 8288) since mdream's frontmatter only accepts string scalars.
|
|
168
|
+
const additionalFrontmatter = { canonical_url: canonicalUrl };
|
|
169
|
+
if (lastUpdated) additionalFrontmatter.last_updated = lastUpdated;
|
|
170
|
+
if (config.i18n) {
|
|
171
|
+
additionalFrontmatter.locale = resolveLocaleFromRoute(path, config.i18n, routeContext).locale;
|
|
172
|
+
}
|
|
173
|
+
const result = await convertHtmlToMarkdown(html, canonicalUrl, config.mdreamOptions, {
|
|
174
|
+
hooks: {
|
|
175
|
+
route: path,
|
|
176
|
+
event,
|
|
177
|
+
isPrerender: false
|
|
178
|
+
},
|
|
179
|
+
additionalFrontmatter
|
|
180
|
+
});
|
|
181
|
+
setMarkdownHeaders(event, ctx, response.headers);
|
|
182
|
+
return finalizeMarkdown(result.markdown);
|
|
163
183
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { defineNitroPlugin, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
2
2
|
export default defineNitroPlugin((nitro) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
AI-Terms: ${href}
|
|
9
|
-
`;
|
|
10
|
-
});
|
|
3
|
+
nitro.hooks.hook("robots:robots-txt", (context) => {
|
|
4
|
+
const href = useRuntimeConfig()["nuxt-ai-ready"].aiTerms?.href;
|
|
5
|
+
if (href) context.robotsTxt = `${context.robotsTxt.trimEnd()}\n\nAI-Terms: ${href}\n`;
|
|
6
|
+
});
|
|
11
7
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -2,12 +2,11 @@ import { defineNitroPlugin, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
2
2
|
import { toLogicalRoute } from "../../route-path.js";
|
|
3
3
|
import { storePrerenderedContentSignal } from "../utils/prerender-html.js";
|
|
4
4
|
export default defineNitroPlugin((nitro) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
5
|
+
const hooks = nitro.hooks;
|
|
6
|
+
hooks.hook("response", (response, event) => {
|
|
7
|
+
const policy = response.headers.get("content-signal");
|
|
8
|
+
const config = useRuntimeConfig();
|
|
9
|
+
const sharedPolicy = config["nuxt-robots"]?.contentSignalHeader;
|
|
10
|
+
if (policy !== null && policy !== sharedPolicy) storePrerenderedContentSignal(toLogicalRoute(event.url.pathname, config.app.baseURL), policy);
|
|
11
|
+
});
|
|
13
12
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -3,11 +3,11 @@ import { defineNitroPlugin, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
3
3
|
import { toLogicalRoute } from "../../route-path.js";
|
|
4
4
|
import { storePrerenderedContentSignal } from "../utils/prerender-html.js";
|
|
5
5
|
export default defineNitroPlugin((nitro) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
nitro.hooks.hook("beforeResponse", (event) => {
|
|
7
|
+
const policy = getResponseHeader(event, "content-signal");
|
|
8
|
+
const config = useRuntimeConfig(event);
|
|
9
|
+
const sharedPolicy = config["nuxt-robots"]?.contentSignalHeader;
|
|
10
|
+
// Nuxt Robots publishes its shared fallback. Per-page copies would consume the static rule budget.
|
|
11
|
+
if (typeof policy === "string" && policy !== sharedPolicy) storePrerenderedContentSignal(toLogicalRoute(getRequestURL(event).pathname, config.app.baseURL), policy);
|
|
12
|
+
});
|
|
13
13
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nitro/types").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { definePlugin } from "nitro";
|
|
2
2
|
import { DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY } from "../db/context.js";
|
|
3
|
-
export default
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
3
|
+
export default definePlugin(({ hooks }) => {
|
|
4
|
+
hooks.hook("response", async (_response, event) => {
|
|
5
|
+
if (!event.context?.[DB_CONTEXT_KEY] && !event.context?.[DB_PROMISE_CONTEXT_KEY] && !event.context?.[DB_WORK_CONTEXT_KEY]) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const { finishDrizzleResponse } = await import("../db/index.js");
|
|
9
|
+
await finishDrizzleResponse(event);
|
|
10
|
+
});
|
|
11
|
+
hooks.hook("close", async () => {
|
|
12
|
+
const { closeDrizzle } = await import("../db/index.js");
|
|
13
|
+
await closeDrizzle();
|
|
14
|
+
});
|
|
16
15
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY } from "../db/context.js";
|
|
2
2
|
export default function dbLifecyclePlugin(nitroApp) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
// Close request-scoped database connection
|
|
4
|
+
nitroApp.hooks.hook("afterResponse", async (event) => {
|
|
5
|
+
if (!event.context?.[DB_CONTEXT_KEY] && !event.context?.[DB_PROMISE_CONTEXT_KEY] && !event.context?.[DB_WORK_CONTEXT_KEY]) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const { finishDrizzleResponse } = await import("../db/index.js");
|
|
9
|
+
await finishDrizzleResponse(event);
|
|
10
|
+
});
|
|
11
|
+
// Close fallback database connection on app close
|
|
12
|
+
nitroApp.hooks.hook("close", async () => {
|
|
13
|
+
const { closeDrizzle } = await import("../db/index.js");
|
|
14
|
+
await closeDrizzle();
|
|
15
|
+
});
|
|
14
16
|
}
|
|
@@ -3,10 +3,10 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
3
3
|
import { toLogicalRoute } from "../../route-path.js";
|
|
4
4
|
import { storePrerenderedHtml } from "../utils/prerender-html.js";
|
|
5
5
|
export default function htmlCapturePlugin(nitroApp) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if (!import.meta.prerender) return;
|
|
7
|
+
nitroApp.hooks.hook("render:html", (html, { event }) => {
|
|
8
|
+
const baseURL = useRuntimeConfig(event).app.baseURL;
|
|
9
|
+
// Keep the context until consumption so later render hooks can finish it.
|
|
10
|
+
storePrerenderedHtml(toLogicalRoute(getRequestURL(event).pathname, baseURL), html);
|
|
11
|
+
});
|
|
12
12
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
2
2
|
export default _default;
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
2
2
|
import { STATUS_AWARE_LINK_HEADER } from "./link-header.js";
|
|
3
3
|
function readHeader(event) {
|
|
4
|
-
|
|
4
|
+
return event.context[STATUS_AWARE_LINK_HEADER];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* H3 returns a handler's own error `Response` unchanged. When it came from
|
|
8
|
+
* `fetch()`, its headers are immutable and `set` throws a TypeError. That
|
|
9
|
+
* response never received the prepared Link header, so it stays as the
|
|
10
|
+
* handler built it. Other errors still reach Nitro's error hook.
|
|
11
|
+
*/
|
|
6
12
|
function setLinkUnlessImmutable(response, value) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
+
try {
|
|
14
|
+
response.headers.set("link", value);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (!(error instanceof TypeError)) throw error;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
export default defineNitroPlugin((nitro) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
// Selected only for Nitro 3. Keep the native hook boundary explicit while
|
|
21
|
+
// the maintainer's app provides Nitro 2 types.
|
|
22
|
+
const hooks = nitro.hooks;
|
|
23
|
+
// The response hook also sees error pages, so error links need no request
|
|
24
|
+
// header here. Request headers are immutable on Cloudflare Workers.
|
|
25
|
+
hooks.hook("response", (response, event) => {
|
|
26
|
+
const header = readHeader(event);
|
|
27
|
+
if (header) {
|
|
28
|
+
setLinkUnlessImmutable(response, response.status >= 400 ? header.error : header.success);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
21
31
|
});
|
|
@@ -6,5 +6,5 @@ export interface StatusAwareLinkHeader {
|
|
|
6
6
|
success: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function setStatusAwareLinkHeader(event: H3Event, safeHeader: string, successHeader?: string): void;
|
|
9
|
-
declare const _default:
|
|
9
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
10
10
|
export default _default;
|
|
@@ -3,36 +3,36 @@ import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
|
3
3
|
export const STATUS_AWARE_LINK_HEADER = "nuxt-ai-ready:status-aware-link-header";
|
|
4
4
|
export const ERROR_LINK_HEADER = "x-nuxt-ai-ready-error-link";
|
|
5
5
|
export function setStatusAwareLinkHeader(event, safeHeader, successHeader) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
event.context[STATUS_AWARE_LINK_HEADER] = {
|
|
7
|
+
error: safeHeader,
|
|
8
|
+
success: successHeader ?? safeHeader
|
|
9
|
+
};
|
|
10
|
+
setHeader(event, "link", safeHeader);
|
|
11
11
|
}
|
|
12
12
|
export default defineNitroPlugin((nitro) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
nitro.hooks.hook("error", (_error, { event }) => {
|
|
14
|
+
if (!event) return;
|
|
15
|
+
const header = event.context[STATUS_AWARE_LINK_HEADER];
|
|
16
|
+
if (header) event.node.req.headers[ERROR_LINK_HEADER] = header.error;
|
|
17
|
+
});
|
|
18
|
+
nitro.hooks.hook("beforeResponse", (event) => {
|
|
19
|
+
// Nitro also calls this hook after a handler has sent the response, such
|
|
20
|
+
// as `proxyRequest` or a 304 from a cached route. Headers are final then.
|
|
21
|
+
if (event.node.res.headersSent) return;
|
|
22
|
+
const header = event.context[STATUS_AWARE_LINK_HEADER];
|
|
23
|
+
if (!header) return;
|
|
24
|
+
setHeader(event, "link", getResponseStatus(event) >= 400 ? header.error : header.success);
|
|
25
|
+
});
|
|
26
|
+
nitro.hooks.hook("render:html", (_html, { event }) => {
|
|
27
|
+
const header = event.context[STATUS_AWARE_LINK_HEADER];
|
|
28
|
+
// Nuxt forwards request headers to its internal error render.
|
|
29
|
+
const errorHeader = event.path.startsWith("/__nuxt_error") ? getHeader(event, ERROR_LINK_HEADER) : undefined;
|
|
30
|
+
if (errorHeader) {
|
|
31
|
+
setHeader(event, "link", errorHeader);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (header) {
|
|
35
|
+
setHeader(event, "link", getResponseStatus(event) >= 400 ? header.error : header.success);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
38
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineNitroPlugin, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
2
2
|
import { llmsTxtDirectiveHtml } from "../../llms-txt-directive.js";
|
|
3
3
|
import { toDeployedRoute } from "../../route-path.js";
|
|
4
|
+
/** Registered only with `llmsTxt.directive.html: true`. */
|
|
4
5
|
export default defineNitroPlugin((nitroApp) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
nitroApp.hooks.hook("render:html", (html, { event }) => {
|
|
7
|
+
html.bodyPrepend.unshift(llmsTxtDirectiveHtml(toDeployedRoute("/llms.txt", useRuntimeConfig(event).app.baseURL)));
|
|
8
|
+
});
|
|
8
9
|
});
|