@farming-labs/svelte 0.1.1-beta.2 → 0.1.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/server.d.ts +2 -0
- package/dist/server.js +30 -1
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* export { load } from "$lib/docs.server";
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
+
import type { DocsMcpHttpHandlers } from "@farming-labs/docs/server";
|
|
30
31
|
import { loadDocsNavTree } from "./content.js";
|
|
31
32
|
import type { PageNode } from "./content.js";
|
|
32
33
|
export { createSvelteApiReference } from "./api-reference.js";
|
|
@@ -54,6 +55,7 @@ export interface DocsServer {
|
|
|
54
55
|
}>;
|
|
55
56
|
GET: (event: RequestEvent) => Response;
|
|
56
57
|
POST: (event: RequestEvent) => Promise<Response>;
|
|
58
|
+
MCP: DocsMcpHttpHandlers;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Create all server-side functions needed for a SvelteKit docs site.
|
package/dist/server.js
CHANGED
|
@@ -31,6 +31,7 @@ import fs from "node:fs";
|
|
|
31
31
|
import path from "node:path";
|
|
32
32
|
import matter from "gray-matter";
|
|
33
33
|
import { resolveDocsI18n, resolveDocsLocale, resolveDocsPath } from "@farming-labs/docs";
|
|
34
|
+
import { createDocsMcpHttpHandler } from "@farming-labs/docs/server";
|
|
34
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
35
36
|
import { renderMarkdown } from "./markdown.js";
|
|
36
37
|
export { createSvelteApiReference } from "./api-reference.js";
|
|
@@ -525,6 +526,13 @@ export function createDocsServer(config = {}) {
|
|
|
525
526
|
llmsCache.set(key, next);
|
|
526
527
|
return next;
|
|
527
528
|
}
|
|
529
|
+
function resolveLocaleForMcp(locale) {
|
|
530
|
+
if (!i18n)
|
|
531
|
+
return undefined;
|
|
532
|
+
if (locale && i18n.locales.includes(locale))
|
|
533
|
+
return locale;
|
|
534
|
+
return i18n.defaultLocale;
|
|
535
|
+
}
|
|
528
536
|
// ─── GET /api/docs?query=… | ?format=llms | ?format=llms-full ──
|
|
529
537
|
function GET(event) {
|
|
530
538
|
const ctx = resolveContextFromRequest(event.request);
|
|
@@ -650,5 +658,26 @@ export function createDocsServer(config = {}) {
|
|
|
650
658
|
},
|
|
651
659
|
});
|
|
652
660
|
}
|
|
653
|
-
|
|
661
|
+
const mcpSiteTitle = typeof config.nav?.title === "string"
|
|
662
|
+
? config.nav.title
|
|
663
|
+
: "Documentation";
|
|
664
|
+
const MCP = createDocsMcpHttpHandler({
|
|
665
|
+
source: {
|
|
666
|
+
entry,
|
|
667
|
+
siteTitle: mcpSiteTitle,
|
|
668
|
+
getPages(locale) {
|
|
669
|
+
const ctx = resolveContextFromPath(`/${entry}`, resolveLocaleForMcp(locale));
|
|
670
|
+
return getSearchIndex(ctx);
|
|
671
|
+
},
|
|
672
|
+
getNavigation(locale) {
|
|
673
|
+
const ctx = resolveContextFromPath(`/${entry}`, resolveLocaleForMcp(locale));
|
|
674
|
+
return preloaded
|
|
675
|
+
? navTreeFromMap(preloaded, ctx.dirPrefix, entry, ordering)
|
|
676
|
+
: loadDocsNavTree(ctx.contentDirAbs, entry, ordering);
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
mcp: config.mcp,
|
|
680
|
+
defaultName: mcpSiteTitle,
|
|
681
|
+
});
|
|
682
|
+
return { load, GET, POST, MCP };
|
|
654
683
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.1.1
|
|
3
|
+
"version": "0.1.1",
|
|
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.1
|
|
59
|
+
"@farming-labs/docs": "0.1.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|