@farming-labs/svelte 0.1.54 → 0.1.57
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/content.d.ts +2 -1
- package/dist/content.js +2 -1
- package/dist/server.js +14 -5
- package/package.json +2 -2
package/dist/content.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* extracts frontmatter, and builds a navigation tree compatible
|
|
6
6
|
* with @farming-labs/docs DocsConfig.
|
|
7
7
|
*/
|
|
8
|
-
import { type OrderingItem, type ResolvedDocsRelatedLink } from "@farming-labs/docs";
|
|
8
|
+
import { type OrderingItem, type ResolvedDocsRelatedLink, type SidebarFolderIndexBehavior } from "@farming-labs/docs";
|
|
9
9
|
export interface PageNode {
|
|
10
10
|
type: "page";
|
|
11
11
|
name: string;
|
|
@@ -18,6 +18,7 @@ export interface FolderNode {
|
|
|
18
18
|
name: string;
|
|
19
19
|
icon?: string;
|
|
20
20
|
index?: PageNode;
|
|
21
|
+
folderIndexBehavior?: SidebarFolderIndexBehavior;
|
|
21
22
|
children: NavNode[];
|
|
22
23
|
}
|
|
23
24
|
export type NavNode = PageNode | FolderNode;
|
package/dist/content.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import matter from "gray-matter";
|
|
11
|
-
import { normalizeDocsRelated, resolveDocsAgentMdxContent, } from "@farming-labs/docs";
|
|
11
|
+
import { normalizeDocsRelated, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, } from "@farming-labs/docs";
|
|
12
12
|
/**
|
|
13
13
|
* Scan a content directory and return all docs pages.
|
|
14
14
|
* Expects a flat or nested structure of `.md` files:
|
|
@@ -121,6 +121,7 @@ function buildNavNode(dir, name, slugParts, entry, ordering, childSlugOrder) {
|
|
|
121
121
|
name: displayName,
|
|
122
122
|
icon,
|
|
123
123
|
index: { type: "page", name: displayName, url, icon },
|
|
124
|
+
folderIndexBehavior: resolvePageSidebarFolderIndexBehavior(data.sidebar),
|
|
124
125
|
children: scanDir(full, slug, entry, ordering, childSlugOrder),
|
|
125
126
|
};
|
|
126
127
|
}
|
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 { buildDocsAgentDiscoverySpec, findDocsMarkdownPage, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsSkillDocument, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSkillFormat, } from "@farming-labs/docs";
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAgentDiscoverySpec, findDocsMarkdownPage, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsSkillDocument, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSkillFormat, } from "@farming-labs/docs";
|
|
34
34
|
import { createDocsMcpHttpHandler, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
@@ -137,6 +137,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
|
|
|
137
137
|
title: data.title ?? fallbackTitle,
|
|
138
138
|
url,
|
|
139
139
|
icon: data.icon,
|
|
140
|
+
folderIndexBehavior: resolvePageSidebarFolderIndexBehavior(data.sidebar),
|
|
140
141
|
order: typeof data.order === "number" ? data.order : Infinity,
|
|
141
142
|
});
|
|
142
143
|
}
|
|
@@ -205,6 +206,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
|
|
|
205
206
|
name: child.title,
|
|
206
207
|
icon: child.icon,
|
|
207
208
|
index: { type: "page", name: child.title, url: child.url, icon: child.icon },
|
|
209
|
+
folderIndexBehavior: child.folderIndexBehavior,
|
|
208
210
|
children: buildLevel(child.parts),
|
|
209
211
|
});
|
|
210
212
|
}
|
|
@@ -239,6 +241,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
|
|
|
239
241
|
url: child.url,
|
|
240
242
|
icon: child.icon,
|
|
241
243
|
},
|
|
244
|
+
folderIndexBehavior: child.folderIndexBehavior,
|
|
242
245
|
children: buildLevel(child.parts),
|
|
243
246
|
});
|
|
244
247
|
}
|
|
@@ -410,9 +413,12 @@ export function createDocsServer(config = {}) {
|
|
|
410
413
|
async function load(event) {
|
|
411
414
|
const locale = resolveDocsLocale(event.url.searchParams, i18n) ?? i18n?.defaultLocale;
|
|
412
415
|
const ctx = resolveContextFromPath(event.url.pathname, locale);
|
|
413
|
-
const tree = preloaded
|
|
416
|
+
const tree = applySidebarFolderIndexBehavior(preloaded
|
|
414
417
|
? navTreeFromMap(preloaded, ctx.dirPrefix, entry, ordering)
|
|
415
|
-
: loadDocsNavTree(ctx.contentDirAbs, entry, ordering)
|
|
418
|
+
: loadDocsNavTree(ctx.contentDirAbs, entry, ordering), {
|
|
419
|
+
sidebar: config.sidebar,
|
|
420
|
+
defaultBehavior: "toggle",
|
|
421
|
+
});
|
|
416
422
|
const flatPages = flattenNavTree(tree);
|
|
417
423
|
const slug = ctx.slug;
|
|
418
424
|
const isIndex = slug === "";
|
|
@@ -810,9 +816,12 @@ export function createDocsServer(config = {}) {
|
|
|
810
816
|
},
|
|
811
817
|
getNavigation(locale) {
|
|
812
818
|
const ctx = resolveContextFromPath(`/${entry}`, resolveLocaleForMcp(locale));
|
|
813
|
-
return preloaded
|
|
819
|
+
return applySidebarFolderIndexBehavior(preloaded
|
|
814
820
|
? navTreeFromMap(preloaded, ctx.dirPrefix, entry, ordering)
|
|
815
|
-
: loadDocsNavTree(ctx.contentDirAbs, entry, ordering)
|
|
821
|
+
: loadDocsNavTree(ctx.contentDirAbs, entry, ordering), {
|
|
822
|
+
sidebar: config.sidebar,
|
|
823
|
+
defaultBehavior: "toggle",
|
|
824
|
+
});
|
|
816
825
|
},
|
|
817
826
|
},
|
|
818
827
|
mcp: config.mcp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.57",
|
|
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.
|
|
59
|
+
"@farming-labs/docs": "0.1.57"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|