nuxt-ai-ready 2.3.3 → 2.3.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
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "2.3.3",
7
+ "version": "2.3.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
@@ -1,18 +1,18 @@
1
1
  import { defineNuxtPlugin, useHead, useRequestURL, useRuntimeConfig } from "nuxt/app";
2
2
  import { joinURL } from "ufo";
3
- import { toMarkdownPath } from "../../markdown-path.js";
3
+ import { markdownAlternatePath } from "../../markdown-path.js";
4
4
  export default defineNuxtPlugin({
5
5
  setup() {
6
6
  const url = useRequestURL();
7
7
  const path = url.pathname;
8
- const lastSegment = path.split("/").pop() || "";
9
- if (lastSegment.includes("."))
8
+ const markdownPath = markdownAlternatePath(path);
9
+ if (!markdownPath)
10
10
  return;
11
11
  const runtimeConfig = useRuntimeConfig();
12
12
  const describedby = runtimeConfig["nuxt-ai-ready"]?.describedby !== false;
13
13
  useHead({
14
14
  link: [
15
- { rel: "alternate", type: "text/markdown", href: toMarkdownPath(path) },
15
+ { rel: "alternate", type: "text/markdown", href: markdownPath },
16
16
  ...describedby ? [{ rel: "describedby", href: joinURL(runtimeConfig.app.baseURL, "llms.txt") }] : []
17
17
  ]
18
18
  });
@@ -1,4 +1,11 @@
1
- /** True for the `/api` namespace and Nitro's `/_*` and `/@*` internal paths. */
1
+ /** True for the `/api` namespace, Nitro's `/_*` paths, and Vite's `/@*` internals. */
2
2
  export declare function isReservedPath(path: string): boolean;
3
3
  export declare function normalizePagePath(path: string): string;
4
4
  export declare function toMarkdownPath(path: string): string;
5
+ /**
6
+ * The `.md` sibling a page may advertise, or null when it has none.
7
+ *
8
+ * Advertising and serving read the same predicate here, so a page cannot link
9
+ * a representation the markdown handler declines.
10
+ */
11
+ export declare function markdownAlternatePath(path: string): string | null;
@@ -1,5 +1,5 @@
1
1
  const RE_TRAILING_SLASHES = /\/+$/;
2
- const RE_RESERVED_PATH = /^\/(?:api(?:\/|$)|_|@)/;
2
+ const RE_RESERVED_PATH = /^\/(?:api(?:\/|$)|_|@(?:id|fs|vite|react-refresh)(?:\/|$))/;
3
3
  export function isReservedPath(path) {
4
4
  return RE_RESERVED_PATH.test(path);
5
5
  }
@@ -12,3 +12,11 @@ export function toMarkdownPath(path) {
12
12
  return "/index.md";
13
13
  return `${normalizedPath}.md`;
14
14
  }
15
+ export function markdownAlternatePath(path) {
16
+ if (isReservedPath(path))
17
+ return null;
18
+ const lastSegment = normalizePagePath(path).split("/").pop() || "";
19
+ if (lastSegment.includes("."))
20
+ return null;
21
+ return toMarkdownPath(path);
22
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "2.3.3",
4
+ "version": "2.3.4",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",