nuxt-ai-ready 1.5.0 → 1.5.1
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 +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/app/plugins/md-alternate.server.js +2 -2
- package/dist/runtime/app/plugins/md-hints.prerender.js +3 -7
- package/dist/runtime/markdown-path.d.ts +1 -0
- package/dist/runtime/markdown-path.js +6 -0
- package/dist/runtime/server/utils/link-header.js +1 -5
- package/dist/runtime/server/utils.d.ts +1 -2
- package/dist/runtime/server/utils.js +3 -5
- package/package.json +6 -6
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
|
|
|
10
10
|
import { parseSitemapXml } from '@nuxtjs/sitemap/utils';
|
|
11
11
|
import { colorize } from 'consola/utils';
|
|
12
12
|
import { withBase } from 'ufo';
|
|
13
|
+
import { toMarkdownPath } from '../dist/runtime/markdown-path.js';
|
|
13
14
|
import { initSchema, computeContentHash, insertPage, queryAllPages, exportDbDump } from '../dist/runtime/server/db/shared.js';
|
|
14
15
|
import { comparePageHashes, submitToIndexNowShared } from '../dist/runtime/server/utils/indexnow-shared.js';
|
|
15
16
|
import { buildLlmsFullTxtHeader, formatPageForLlmsFullTxt } from '../dist/runtime/server/utils/llms-full.js';
|
|
@@ -163,7 +164,7 @@ async function processSitemapEntry(state, nuxt, nitro, entry) {
|
|
|
163
164
|
if (state.prerenderedRoutes.has(route)) {
|
|
164
165
|
return { crawled: false, skipped: true };
|
|
165
166
|
}
|
|
166
|
-
const mdRoute = route
|
|
167
|
+
const mdRoute = toMarkdownPath(route);
|
|
167
168
|
const mdUrl = withBase(mdRoute, nitro.options.baseURL);
|
|
168
169
|
logger.debug(`Fetching markdown for ${route} \u2192 ${mdUrl}`);
|
|
169
170
|
const res = await globalThis.$fetch(mdUrl, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useHead, useRequestURL } from "nuxt/app";
|
|
2
|
+
import { toMarkdownPath } from "../../markdown-path.js";
|
|
2
3
|
export default defineNuxtPlugin({
|
|
3
4
|
setup() {
|
|
4
5
|
const url = useRequestURL();
|
|
@@ -6,10 +7,9 @@ export default defineNuxtPlugin({
|
|
|
6
7
|
const lastSegment = path.split("/").pop() || "";
|
|
7
8
|
if (lastSegment.includes("."))
|
|
8
9
|
return;
|
|
9
|
-
const mdPath = path === "/" ? "/index.md" : `${path.replace(/\/$/, "")}.md`;
|
|
10
10
|
useHead({
|
|
11
11
|
link: [
|
|
12
|
-
{ rel: "alternate", type: "text/markdown", href:
|
|
12
|
+
{ rel: "alternate", type: "text/markdown", href: toMarkdownPath(path) }
|
|
13
13
|
]
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { isPathFile } from "nuxt-site-config/urls";
|
|
2
2
|
import { defineNuxtPlugin, prerenderRoutes } from "nuxt/app";
|
|
3
|
+
import { toMarkdownPath } from "../../markdown-path.js";
|
|
3
4
|
export default defineNuxtPlugin({
|
|
4
5
|
setup(nuxtApp) {
|
|
5
6
|
if (!import.meta.prerender) {
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
9
|
nuxtApp.hooks.hook("app:rendered", (ctx) => {
|
|
9
|
-
|
|
10
|
+
const url = ctx.ssrContext?.url || "";
|
|
10
11
|
if (isPathFile(url) || ctx.ssrContext?.error || ctx.ssrContext?.noSSR) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
url = `${url}index.md`;
|
|
15
|
-
} else {
|
|
16
|
-
url = `${url}.md`;
|
|
17
|
-
}
|
|
18
|
-
prerenderRoutes(url);
|
|
14
|
+
prerenderRoutes(toMarkdownPath(url));
|
|
19
15
|
});
|
|
20
16
|
}
|
|
21
17
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toMarkdownPath(path: string): string;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { toMarkdownPath } from "../../markdown-path.js";
|
|
1
2
|
import { computeLocaleAlternates } from "./i18n.js";
|
|
2
3
|
export function encodePathForHeader(path) {
|
|
3
4
|
return encodeURI(path);
|
|
4
5
|
}
|
|
5
|
-
function toMarkdownPath(path) {
|
|
6
|
-
if (path === "/" || path.endsWith("/"))
|
|
7
|
-
return `${path}index.md`;
|
|
8
|
-
return `${path}.md`;
|
|
9
|
-
}
|
|
10
6
|
function resolveHeaderUrl(path, resolveUrl) {
|
|
11
7
|
if (!resolveUrl)
|
|
12
8
|
return path;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContentNegotiationResult } from '@mdream/js/negotiate';
|
|
2
2
|
import type { H3Event } from 'h3';
|
|
3
3
|
import type { ModulePublicRuntimeConfig } from '../../module.js';
|
|
4
|
+
export { toMarkdownPath } from '../markdown-path.js';
|
|
4
5
|
export declare function negotiateRepresentation(event: H3Event): ContentNegotiationResult;
|
|
5
6
|
export declare function getMarkdownRenderInfo(event: H3Event, explicitOnly?: boolean): {
|
|
6
7
|
path: string;
|
|
@@ -9,7 +10,6 @@ export declare function getMarkdownRenderInfo(event: H3Event, explicitOnly?: boo
|
|
|
9
10
|
} | {
|
|
10
11
|
notAcceptable: true;
|
|
11
12
|
} | null;
|
|
12
|
-
export declare function toMarkdownPath(path: string): string;
|
|
13
13
|
export declare function clientPrefersMarkdown(event: H3Event): boolean;
|
|
14
14
|
export declare function extractLastUpdated(html: string): string | undefined;
|
|
15
15
|
interface ConvertHtmlOptions {
|
|
@@ -32,4 +32,3 @@ export declare function convertHtmlToMarkdown(html: string, url: string, mdreamO
|
|
|
32
32
|
metaKeywords: string;
|
|
33
33
|
textContent: string;
|
|
34
34
|
}>;
|
|
35
|
-
export {};
|
|
@@ -3,6 +3,7 @@ import { getBotInfo } from "@nuxtjs/robots/util";
|
|
|
3
3
|
import { getHeader, getHeaders } from "h3";
|
|
4
4
|
import { htmlToMarkdown } from "mdream";
|
|
5
5
|
import { useNitroApp } from "nitropack/runtime";
|
|
6
|
+
export { toMarkdownPath } from "../markdown-path.js";
|
|
6
7
|
const RE_NBSP = /\u00A0/g;
|
|
7
8
|
function normalizeWhitespace(text) {
|
|
8
9
|
return text.replace(RE_NBSP, " ");
|
|
@@ -47,6 +48,8 @@ function buildMdreamOptions(url, mdreamOptions, meta, extractUpdatedAt, addition
|
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
export function negotiateRepresentation(event) {
|
|
51
|
+
if (import.meta.prerender || getHeader(event, "x-nitro-prerender"))
|
|
52
|
+
return "html";
|
|
50
53
|
const accept = getHeader(event, "accept");
|
|
51
54
|
const secFetchDest = getHeader(event, "sec-fetch-dest");
|
|
52
55
|
if (negotiateContent(accept) === "markdown")
|
|
@@ -91,11 +94,6 @@ function normalizePath(path) {
|
|
|
91
94
|
return path.slice(0, -5) || "/";
|
|
92
95
|
return path;
|
|
93
96
|
}
|
|
94
|
-
export function toMarkdownPath(path) {
|
|
95
|
-
if (path === "/" || path.endsWith("/"))
|
|
96
|
-
return `${path}index.md`;
|
|
97
|
-
return `${path}.md`;
|
|
98
|
-
}
|
|
99
97
|
export function clientPrefersMarkdown(event) {
|
|
100
98
|
return negotiateRepresentation(event) === "markdown";
|
|
101
99
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ai-ready",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"description": "Best practice AI & LLM discoverability for Nuxt sites.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"defu": "^6.1.7",
|
|
65
65
|
"drizzle-orm": "^0.45.2",
|
|
66
66
|
"mdream": "^1.4.1",
|
|
67
|
-
"nuxt-site-config": "^4.1.
|
|
68
|
-
"nuxtseo-shared": "^5.3.
|
|
67
|
+
"nuxt-site-config": "^4.1.1",
|
|
68
|
+
"nuxtseo-shared": "^5.3.1",
|
|
69
69
|
"pathe": "^2.0.3",
|
|
70
70
|
"pkg-types": "^2.3.1",
|
|
71
|
-
"site-config-stack": "^4.1.
|
|
71
|
+
"site-config-stack": "^4.1.1",
|
|
72
72
|
"ufo": "^1.6.4",
|
|
73
73
|
"uncrypto": "^0.1.3"
|
|
74
74
|
},
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"happy-dom": "^20.10.6",
|
|
96
96
|
"nitropack": "^2.13.4",
|
|
97
97
|
"nuxt": "^4.4.8",
|
|
98
|
-
"nuxt-site-config": "^4.1.
|
|
99
|
-
"nuxtseo-layer-devtools": "^5.3.
|
|
98
|
+
"nuxt-site-config": "^4.1.1",
|
|
99
|
+
"nuxtseo-layer-devtools": "^5.3.1",
|
|
100
100
|
"playwright": "^1.61.1",
|
|
101
101
|
"playwright-core": "^1.61.1",
|
|
102
102
|
"tinyglobby": "^0.2.17",
|