@farming-labs/svelte 0.1.38 → 0.1.41

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
@@ -12,7 +12,7 @@
12
12
  * import config from "./docs.config";
13
13
  *
14
14
  * // Bundle content at build time for serverless deployments
15
- * const contentFiles = import.meta.glob("/docs/**\/*.{md,mdx,svx}", {
15
+ * const contentFiles = import.meta.glob(["/docs/**\/*.{md,mdx,svx}", "/skill.md"], {
16
16
  * query: "?raw", import: "default", eager: true,
17
17
  * }) as Record<string, string>;
18
18
  *
package/dist/server.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * import config from "./docs.config";
13
13
  *
14
14
  * // Bundle content at build time for serverless deployments
15
- * const contentFiles = import.meta.glob("/docs/**\/*.{md,mdx,svx}", {
15
+ * const contentFiles = import.meta.glob(["/docs/**\/*.{md,mdx,svx}", "/skill.md"], {
16
16
  * query: "?raw", import: "default", eager: true,
17
17
  * }) as Record<string, string>;
18
18
  *
@@ -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, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, resolveDocsAgentMdxContent, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, } from "@farming-labs/docs";
33
+ import { buildDocsAgentDiscoverySpec, findDocsMarkdownPage, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsSkillDocument, resolveDocsAgentMdxContent, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, 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";
@@ -95,6 +95,25 @@ function buildDirPrefix(contentDir) {
95
95
  const normalized = normalizePathSegment(rel);
96
96
  return normalized ? `/${normalized}/` : "/";
97
97
  }
98
+ function readRootSkillDocument(contentMap, rootDir) {
99
+ if (contentMap) {
100
+ for (const key of ["/skill.md", "skill.md", "./skill.md"]) {
101
+ const raw = contentMap[key];
102
+ if (typeof raw === "string")
103
+ return raw;
104
+ }
105
+ }
106
+ const candidate = path.join(rootDir, "skill.md");
107
+ try {
108
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
109
+ return fs.readFileSync(candidate, "utf-8");
110
+ }
111
+ }
112
+ catch {
113
+ return null;
114
+ }
115
+ return null;
116
+ }
98
117
  function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
99
118
  const dirs = [];
100
119
  for (const key of Object.keys(contentMap)) {
@@ -320,6 +339,7 @@ function findPageInMap(contentMap, dirPrefix, slug) {
320
339
  export function createDocsServer(config = {}) {
321
340
  const entry = config.entry ?? "docs";
322
341
  const contentDirBase = config.contentDir ?? entry;
342
+ const rootDir = path.resolve(config.rootDir ?? process.cwd());
323
343
  const i18n = resolveDocsI18n(config.i18n);
324
344
  const githubRaw = config.github;
325
345
  const github = typeof githubRaw === "string" ? { url: githubRaw } : (githubRaw ?? null);
@@ -595,6 +615,30 @@ export function createDocsServer(config = {}) {
595
615
  },
596
616
  });
597
617
  }
618
+ if (isDocsSkillRequest(event.url) || resolveDocsSkillFormat(event.url) === "skill") {
619
+ return new Response(readRootSkillDocument(preloaded, rootDir) ??
620
+ renderDocsSkillDocument({
621
+ origin: event.url.origin,
622
+ entry,
623
+ search: config.search,
624
+ mcp: mcpConfig,
625
+ llms: {
626
+ enabled: llmsEnabled,
627
+ baseUrl: llmsBaseUrl || undefined,
628
+ siteTitle: llmsTitle,
629
+ siteDescription: llmsDesc,
630
+ },
631
+ markdown: {
632
+ acceptHeader: false,
633
+ },
634
+ }), {
635
+ headers: {
636
+ "Content-Type": "text/markdown; charset=utf-8",
637
+ "Cache-Control": "public, max-age=0, s-maxage=3600",
638
+ "X-Robots-Tag": "noindex",
639
+ },
640
+ });
641
+ }
598
642
  const markdownRequest = resolveDocsMarkdownRequest(entry, event.url, event.request);
599
643
  if (markdownRequest) {
600
644
  const document = getMarkdownDocument(ctx, markdownRequest.requestedPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte",
3
- "version": "0.1.38",
3
+ "version": "0.1.41",
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.38"
59
+ "@farming-labs/docs": "0.1.41"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@farming-labs/docs": "*"