@farming-labs/svelte 0.1.2 → 0.1.3

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/server.d.ts CHANGED
@@ -53,7 +53,7 @@ export interface DocsServer {
53
53
  editOnGithub?: string;
54
54
  lastModified: string;
55
55
  }>;
56
- GET: (event: RequestEvent) => Response;
56
+ GET: (event: RequestEvent) => Promise<Response>;
57
57
  POST: (event: RequestEvent) => Promise<Response>;
58
58
  MCP: DocsMcpHttpHandlers;
59
59
  }
package/dist/server.js CHANGED
@@ -30,7 +30,7 @@
30
30
  import fs from "node:fs";
31
31
  import path from "node:path";
32
32
  import matter from "gray-matter";
33
- import { resolveDocsI18n, resolveDocsLocale, resolveDocsPath } from "@farming-labs/docs";
33
+ import { performDocsSearch, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLocale, resolveDocsPath, } from "@farming-labs/docs";
34
34
  import { createDocsMcpHttpHandler } from "@farming-labs/docs/server";
35
35
  import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
36
36
  import { renderMarkdown } from "./markdown.js";
@@ -534,7 +534,7 @@ export function createDocsServer(config = {}) {
534
534
  return i18n.defaultLocale;
535
535
  }
536
536
  // ─── GET /api/docs?query=… | ?format=llms | ?format=llms-full ──
537
- function GET(event) {
537
+ async function GET(event) {
538
538
  const ctx = resolveContextFromRequest(event.request);
539
539
  const format = event.url.searchParams.get("format");
540
540
  if (format === "llms" || format === "llms-full") {
@@ -546,19 +546,20 @@ export function createDocsServer(config = {}) {
546
546
  },
547
547
  });
548
548
  }
549
- const query = event.url.searchParams.get("query")?.toLowerCase().trim();
549
+ const query = event.url.searchParams.get("query")?.trim();
550
550
  if (!query) {
551
551
  return new Response(JSON.stringify([]), {
552
552
  headers: { "Content-Type": "application/json" },
553
553
  });
554
554
  }
555
- const results = searchByQuery(query, ctx)
556
- .slice(0, 10)
557
- .map(({ title, url, description }) => ({
558
- content: title,
559
- url,
560
- description,
561
- }));
555
+ const results = await performDocsSearch({
556
+ pages: getSearchIndex(ctx),
557
+ query,
558
+ search: resolveSearchRequestConfig(config.search, event.request.url),
559
+ locale: ctx.locale,
560
+ pathname: event.url.searchParams.get("pathname") ?? undefined,
561
+ siteTitle: llmsTitle,
562
+ });
562
563
  return new Response(JSON.stringify(results), {
563
564
  headers: { "Content-Type": "application/json" },
564
565
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
5
5
  "keywords": [
6
6
  "docs",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@types/node": "^22.10.0",
58
58
  "typescript": "^5.9.3",
59
- "@farming-labs/docs": "0.1.2"
59
+ "@farming-labs/docs": "0.1.3"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@farming-labs/docs": "*"