nuxt-ai-ready 0.4.2 → 0.4.4
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -227,7 +227,13 @@ async function crawlSitemapEntries(state, nuxt, nitro, entries) {
|
|
|
227
227
|
});
|
|
228
228
|
if (!res)
|
|
229
229
|
continue;
|
|
230
|
-
|
|
230
|
+
let parsed;
|
|
231
|
+
try {
|
|
232
|
+
parsed = JSON.parse(res);
|
|
233
|
+
} catch (err) {
|
|
234
|
+
logger.debug(`Skipping ${route}: Response is not JSON (likely HTML instead of markdown conversion)`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
231
237
|
await processMarkdownRoute(state, nuxt, route, parsed, lastmod);
|
|
232
238
|
crawled++;
|
|
233
239
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { withSiteUrl } from "#site-config/server/composables/utils";
|
|
2
|
-
import { createError, defineEventHandler, setHeader } from "h3";
|
|
2
|
+
import { createError, defineEventHandler, getHeader, setHeader } from "h3";
|
|
3
3
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
4
4
|
import { logger } from "../logger.js";
|
|
5
5
|
import { convertHtmlToMarkdown, getMarkdownRenderInfo } from "../utils.js";
|
|
6
|
+
const INTERNAL_HEADER = "x-ai-ready-internal";
|
|
6
7
|
export default defineEventHandler(async (event) => {
|
|
8
|
+
if (getHeader(event, INTERNAL_HEADER))
|
|
9
|
+
return;
|
|
7
10
|
const renderInfo = getMarkdownRenderInfo(event);
|
|
8
11
|
if (!renderInfo)
|
|
9
12
|
return;
|
|
10
13
|
const { path, isExplicit } = renderInfo;
|
|
11
14
|
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
12
|
-
const response = await event.fetch(path
|
|
15
|
+
const response = await event.fetch(path, {
|
|
16
|
+
headers: { [INTERNAL_HEADER]: "1" }
|
|
17
|
+
}).catch((e) => {
|
|
13
18
|
logger.error(`Failed to fetch HTML for ${path}`, e);
|
|
14
19
|
return null;
|
|
15
20
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getBotInfo } from "@nuxtjs/robots/util";
|
|
2
|
+
import { getHeader, getHeaders } from "h3";
|
|
2
3
|
import { htmlToMarkdown } from "mdream";
|
|
3
4
|
import { extractionPlugin } from "mdream/plugins";
|
|
4
5
|
import { withMinimalPreset } from "mdream/preset/minimal";
|
|
@@ -40,7 +41,14 @@ export function clientPrefersMarkdown(event) {
|
|
|
40
41
|
if (accept.includes("text/html")) {
|
|
41
42
|
return false;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
if (accept.includes("text/markdown")) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
const botInfo = getBotInfo(getHeaders(event));
|
|
48
|
+
if (botInfo?.category === "ai") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
44
52
|
}
|
|
45
53
|
export async function convertHtmlToMarkdown(html, url, config, route, event) {
|
|
46
54
|
const nitroApp = useNitroApp();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ai-ready",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"description": "Best practice AI & LLM discoverability for Nuxt sites.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"postgres": "^3.4.7",
|
|
78
78
|
"typescript": "^5.9.3",
|
|
79
79
|
"vitest": "^4.0.16",
|
|
80
|
-
"vue": "^3.5.
|
|
80
|
+
"vue": "^3.5.26",
|
|
81
81
|
"vue-router": "^4.6.4",
|
|
82
82
|
"vue-tsc": "^3.1.8",
|
|
83
83
|
"zod": "^4.2.1"
|