@farming-labs/svelte 0.0.2-beta.22 → 0.0.2-beta.23

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.
Files changed (2) hide show
  1. package/dist/server.js +44 -1
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -383,8 +383,51 @@ export function createDocsServer(config = {}) {
383
383
  .filter((r) => r.score > 0)
384
384
  .sort((a, b) => b.score - a.score);
385
385
  }
386
- // ─── GET /api/docs?query=… full-text search ────────────
386
+ // ─── llms.txt content builder ────────────────────────────────
387
+ const llmsSiteTitle = typeof config.nav === "object" &&
388
+ typeof config.nav?.title === "string"
389
+ ? config.nav.title
390
+ : "Documentation";
391
+ const llmsTxtConfig = config.llmsTxt;
392
+ const llmsBaseUrl = typeof llmsTxtConfig === "object" ? (llmsTxtConfig.baseUrl ?? "") : "";
393
+ const llmsTitle = typeof llmsTxtConfig === "object" ? (llmsTxtConfig.siteTitle ?? llmsSiteTitle) : llmsSiteTitle;
394
+ const llmsDesc = typeof llmsTxtConfig === "object" ? llmsTxtConfig.siteDescription : undefined;
395
+ function buildLlmsTxt(full) {
396
+ const pages = getSearchIndex();
397
+ let out = `# ${llmsTitle}\n\n`;
398
+ if (llmsDesc)
399
+ out += `> ${llmsDesc}\n\n`;
400
+ if (full) {
401
+ for (const page of pages) {
402
+ out += `## ${page.title}\n\n`;
403
+ out += `URL: ${llmsBaseUrl}${page.url}\n\n`;
404
+ if (page.description)
405
+ out += `${page.description}\n\n`;
406
+ out += `${page.content}\n\n---\n\n`;
407
+ }
408
+ }
409
+ else {
410
+ out += `## Pages\n\n`;
411
+ for (const page of pages) {
412
+ out += `- [${page.title}](${llmsBaseUrl}${page.url})`;
413
+ if (page.description)
414
+ out += `: ${page.description}`;
415
+ out += `\n`;
416
+ }
417
+ }
418
+ return out;
419
+ }
420
+ // ─── GET /api/docs?query=… | ?format=llms | ?format=llms-full ──
387
421
  function GET(event) {
422
+ const format = event.url.searchParams.get("format");
423
+ if (format === "llms" || format === "llms-full") {
424
+ return new Response(buildLlmsTxt(format === "llms-full"), {
425
+ headers: {
426
+ "Content-Type": "text/plain; charset=utf-8",
427
+ "Cache-Control": "public, max-age=3600",
428
+ },
429
+ });
430
+ }
388
431
  const query = event.url.searchParams.get("query")?.toLowerCase().trim();
389
432
  if (!query) {
390
433
  return new Response(JSON.stringify([]), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte",
3
- "version": "0.0.2-beta.22",
3
+ "version": "0.0.2-beta.23",
4
4
  "description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
5
5
  "keywords": [
6
6
  "docs",
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.10.0",
52
52
  "typescript": "^5.9.3",
53
- "@farming-labs/docs": "0.0.2-beta.22"
53
+ "@farming-labs/docs": "0.0.2-beta.23"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@farming-labs/docs": "*"