@farming-labs/svelte 0.1.12 → 0.1.16

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 CHANGED
@@ -33,6 +33,8 @@ export interface ContentPage {
33
33
  icon?: string;
34
34
  content: string;
35
35
  rawContent: string;
36
+ agentContent?: string;
37
+ agentRawContent?: string;
36
38
  }
37
39
  /**
38
40
  * Scan a content directory and return all docs pages.
package/dist/content.js CHANGED
@@ -29,6 +29,8 @@ export function loadDocsContent(contentDir, entry = "docs") {
29
29
  scan(full, [...slugParts, name]);
30
30
  continue;
31
31
  }
32
+ if (name === "agent.md")
33
+ continue;
32
34
  if (!name.endsWith(".md") && !name.endsWith(".mdx") && !name.endsWith(".svx"))
33
35
  continue;
34
36
  const raw = fs.readFileSync(full, "utf-8");
@@ -37,6 +39,7 @@ export function loadDocsContent(contentDir, entry = "docs") {
37
39
  const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
38
40
  const slug = isIndex ? slugParts.join("/") : [...slugParts, baseName].join("/");
39
41
  const url = slug ? `/${entry}/${slug}` : `/${entry}`;
42
+ const agentDoc = isIndex ? readAgentDoc(dir) : undefined;
40
43
  const title = data.title ??
41
44
  baseName.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
42
45
  pages.push({
@@ -47,12 +50,24 @@ export function loadDocsContent(contentDir, entry = "docs") {
47
50
  icon: data.icon,
48
51
  content: stripMarkdown(content),
49
52
  rawContent: content,
53
+ ...agentDoc,
50
54
  });
51
55
  }
52
56
  }
53
57
  scan(absDir, []);
54
58
  return pages;
55
59
  }
60
+ function readAgentDoc(dir) {
61
+ const agentPath = path.join(dir, "agent.md");
62
+ if (!fs.existsSync(agentPath))
63
+ return undefined;
64
+ const raw = fs.readFileSync(agentPath, "utf-8");
65
+ const { content } = matter(raw);
66
+ return {
67
+ agentContent: stripMarkdown(content),
68
+ agentRawContent: content,
69
+ };
70
+ }
56
71
  /**
57
72
  * Build a navigation tree from a content directory.
58
73
  */
package/dist/server.js CHANGED
@@ -245,11 +245,14 @@ function searchIndexFromMap(contentMap, dirPrefix, entry) {
245
245
  const rel = key.slice(dirPrefix.length);
246
246
  const segments = rel.split("/");
247
247
  const fileName = segments.pop();
248
+ if (fileName === "agent.md")
249
+ continue;
248
250
  const base = fileName.replace(/\.(md|mdx|svx)$/, "");
249
251
  const isIdx = base === "page" || base === "index" || base === "+page";
250
252
  const slug = isIdx ? segments.join("/") : [...segments, base].join("/");
251
253
  const url = slug ? `/${entry}/${slug}` : `/${entry}`;
252
254
  const { data, content } = matter(raw);
255
+ const agentDoc = isIdx ? readAgentDocFromMap(contentMap, dirPrefix, slug) : undefined;
253
256
  const title = data.title ?? base.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
254
257
  pages.push({
255
258
  slug,
@@ -259,10 +262,22 @@ function searchIndexFromMap(contentMap, dirPrefix, entry) {
259
262
  icon: data.icon,
260
263
  content: stripMarkdownText(content),
261
264
  rawContent: content,
265
+ ...agentDoc,
262
266
  });
263
267
  }
264
268
  return pages;
265
269
  }
270
+ function readAgentDocFromMap(contentMap, dirPrefix, slug) {
271
+ const key = slug ? `${dirPrefix}${slug}/agent.md` : `${dirPrefix}agent.md`;
272
+ const raw = contentMap[key];
273
+ if (!raw)
274
+ return undefined;
275
+ const { content } = matter(raw);
276
+ return {
277
+ agentContent: stripMarkdownText(content),
278
+ agentRawContent: content,
279
+ };
280
+ }
266
281
  function findPageInMap(contentMap, dirPrefix, slug) {
267
282
  const isIndex = slug === "";
268
283
  const candidates = isIndex
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte",
3
- "version": "0.1.12",
3
+ "version": "0.1.16",
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.12"
59
+ "@farming-labs/docs": "0.1.16"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@farming-labs/docs": "*"