nuxt-ai-ready 0.0.1 → 0.0.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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "0.0.1",
7
+ "version": "0.0.2",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -11,48 +11,11 @@ import { readPackageJSON } from 'pkg-types';
11
11
  import { estimateTokenCount } from 'tokenx';
12
12
  import { writeFile } from 'node:fs/promises';
13
13
  import { join } from 'node:path';
14
- import { consola } from 'consola';
15
14
  import { generateLlmsTxtArtifacts } from 'mdream/llms-txt';
15
+ import { normalizeLlmsTxtConfig } from '../dist/runtime/llms-txt.js';
16
16
 
17
- const logger$1 = useLogger("nuxt-ai-ready");
17
+ const logger = useLogger("nuxt-ai-ready");
18
18
 
19
- function normalizeLink(link) {
20
- const parts = [];
21
- parts.push(`- [${link.title}](${link.href})`);
22
- if (link.description) {
23
- parts.push(` ${link.description}`);
24
- }
25
- return parts.join("\n");
26
- }
27
- function normalizeSection(section) {
28
- const parts = [];
29
- parts.push(`## ${section.title}`);
30
- parts.push("");
31
- if (section.description) {
32
- const descriptions = Array.isArray(section.description) ? section.description : [section.description];
33
- parts.push(...descriptions);
34
- parts.push("");
35
- }
36
- if (section.links?.length) {
37
- parts.push(...section.links.map(normalizeLink));
38
- }
39
- return parts.join("\n");
40
- }
41
- function normalizeLlmsTxtConfig(config) {
42
- const parts = [];
43
- if (config.sections?.length) {
44
- parts.push(...config.sections.map(normalizeSection));
45
- }
46
- if (config.notes) {
47
- parts.push("## Notes");
48
- parts.push("");
49
- const notes = Array.isArray(config.notes) ? config.notes : [config.notes];
50
- parts.push(...notes);
51
- }
52
- return parts.join("\n\n");
53
- }
54
-
55
- const logger = consola.withTag("nuxt-mdream");
56
19
  function setupPrerenderHandler() {
57
20
  const nuxt = useNuxt();
58
21
  const pages = [];
@@ -188,9 +151,9 @@ const module = defineNuxtModule({
188
151
  async setup(config, nuxt) {
189
152
  const { resolve: resolve$1 } = createResolver(import.meta.url);
190
153
  const { version } = await readPackageJSON(resolve$1("../package.json"));
191
- logger$1.level = config.debug || nuxt.options.debug ? 4 : 3;
154
+ logger.level = config.debug || nuxt.options.debug ? 4 : 3;
192
155
  if (config.enabled === false) {
193
- logger$1.debug("Module is disabled, skipping setup.");
156
+ logger.debug("Module is disabled, skipping setup.");
194
157
  return;
195
158
  }
196
159
  await installNuxtSiteConfig();
@@ -314,11 +277,11 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
314
277
  nuxt.hooks.hook("modules:done", () => {
315
278
  nuxt.hook("nitro:init", async (nitro) => {
316
279
  if (!isBuildMode) {
317
- logger$1.debug("Dev mode: skipping llms.txt generation");
280
+ logger.debug("Dev mode: skipping llms.txt generation");
318
281
  return;
319
282
  }
320
283
  if (config.bulkRoute === false) {
321
- logger$1.debug("Bulk route disabled, skipping bulk generation");
284
+ logger.debug("Bulk route disabled, skipping bulk generation");
322
285
  return;
323
286
  }
324
287
  const bulkPath = resolve(nitro.options.output.dir, `public${config.bulkRoute}`);
@@ -364,7 +327,7 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
364
327
  if (!bulkStream) {
365
328
  mkdirSync(dirname(bulkPath), { recursive: true });
366
329
  bulkStream = createWriteStream(bulkPath);
367
- logger$1.info(`Bulk JSONL stream created at ${relative(nuxt.options.rootDir, bulkPath)}`);
330
+ logger.info(`Bulk JSONL stream created at ${relative(nuxt.options.rootDir, bulkPath)}`);
368
331
  }
369
332
  let idx = 0;
370
333
  for (const chunk of chunksStream) {
@@ -394,7 +357,7 @@ Returns JSONL (newline-delimited JSON) with all indexed content.`
394
357
  nitro.hooks.hook("prerender:done", () => {
395
358
  if (bulkStream) {
396
359
  bulkStream.end();
397
- logger$1.success(`Bulk JSONL exported ${bulkStreamEntries} entries.`);
360
+ logger.success(`Bulk JSONL exported ${bulkStreamEntries} entries.`);
398
361
  }
399
362
  });
400
363
  });
@@ -0,0 +1,5 @@
1
+ import type { LlmsTxtConfig } from './types.js';
2
+ /**
3
+ * Normalize llms.txt structured configuration to markdown string
4
+ */
5
+ export declare function normalizeLlmsTxtConfig(config: LlmsTxtConfig): string;
@@ -0,0 +1,35 @@
1
+ function normalizeLink(link) {
2
+ const parts = [];
3
+ parts.push(`- [${link.title}](${link.href})`);
4
+ if (link.description) {
5
+ parts.push(` ${link.description}`);
6
+ }
7
+ return parts.join("\n");
8
+ }
9
+ function normalizeSection(section) {
10
+ const parts = [];
11
+ parts.push(`## ${section.title}`);
12
+ parts.push("");
13
+ if (section.description) {
14
+ const descriptions = Array.isArray(section.description) ? section.description : [section.description];
15
+ parts.push(...descriptions);
16
+ parts.push("");
17
+ }
18
+ if (section.links?.length) {
19
+ parts.push(...section.links.map(normalizeLink));
20
+ }
21
+ return parts.join("\n");
22
+ }
23
+ export function normalizeLlmsTxtConfig(config) {
24
+ const parts = [];
25
+ if (config.sections?.length) {
26
+ parts.push(...config.sections.map(normalizeSection));
27
+ }
28
+ if (config.notes) {
29
+ parts.push("## Notes");
30
+ parts.push("");
31
+ const notes = Array.isArray(config.notes) ? config.notes : [config.notes];
32
+ parts.push(...notes);
33
+ }
34
+ return parts.join("\n\n");
35
+ }
@@ -1,7 +1,7 @@
1
1
  import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
2
2
  import { eventHandler, setHeader } from "h3";
3
3
  import { useRuntimeConfig } from "nitropack/runtime";
4
- import { normalizeLlmsTxtConfig } from "../../../utils";
4
+ import { normalizeLlmsTxtConfig } from "../../llms-txt.js";
5
5
  export default eventHandler(async (event) => {
6
6
  const runtimeConfig = useRuntimeConfig(event)["nuxt-ai-ready"];
7
7
  const siteConfig = getSiteConfig(event);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",