@farming-labs/svelte 0.1.88 → 0.1.90
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.js +38 -25
- package/package.json +2 -2
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 { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsMarkdownVaryHeader, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n,
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, renderDocsLlmsTxt, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsSkillFormat, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, } from "@farming-labs/docs";
|
|
34
34
|
import { createDocsMcpHttpHandler, readDocsSitemapManifest, resolveDocsMcpConfig, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
@@ -588,26 +588,13 @@ export function createDocsServer(config = {}) {
|
|
|
588
588
|
const cached = llmsCache.get(key);
|
|
589
589
|
if (cached)
|
|
590
590
|
return cached;
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
llmsTxt += `## Pages\n\n`;
|
|
599
|
-
for (const page of pages) {
|
|
600
|
-
llmsTxt += `- [${page.title}](${llmsBaseUrl}${toDocsMarkdownUrl(page.url)})`;
|
|
601
|
-
if (page.description)
|
|
602
|
-
llmsTxt += `: ${page.description}`;
|
|
603
|
-
llmsTxt += `\n`;
|
|
604
|
-
llmsFullTxt += `## ${page.title}\n\n`;
|
|
605
|
-
llmsFullTxt += `URL: ${llmsBaseUrl}${page.url}\n\n`;
|
|
606
|
-
if (page.description)
|
|
607
|
-
llmsFullTxt += `${page.description}\n\n`;
|
|
608
|
-
llmsFullTxt += `${page.content}\n\n---\n\n`;
|
|
609
|
-
}
|
|
610
|
-
const next = { llmsTxt, llmsFullTxt };
|
|
591
|
+
const next = renderDocsLlmsTxt(getSearchIndex(ctx), {
|
|
592
|
+
siteTitle: llmsTitle,
|
|
593
|
+
siteDescription: llmsDesc,
|
|
594
|
+
baseUrl: llmsBaseUrl,
|
|
595
|
+
maxChars: typeof llmsTxtConfig === "object" ? llmsTxtConfig.maxChars : undefined,
|
|
596
|
+
sections: typeof llmsTxtConfig === "object" ? llmsTxtConfig.sections : undefined,
|
|
597
|
+
});
|
|
611
598
|
llmsCache.set(key, next);
|
|
612
599
|
return next;
|
|
613
600
|
}
|
|
@@ -637,6 +624,8 @@ export function createDocsServer(config = {}) {
|
|
|
637
624
|
baseUrl: llmsBaseUrl || undefined,
|
|
638
625
|
siteTitle: llmsTitle,
|
|
639
626
|
siteDescription: llmsDesc,
|
|
627
|
+
maxChars: typeof llmsTxtConfig === "object" ? llmsTxtConfig.maxChars : undefined,
|
|
628
|
+
sections: typeof llmsTxtConfig === "object" ? llmsTxtConfig.sections : undefined,
|
|
640
629
|
},
|
|
641
630
|
sitemap: config.sitemap,
|
|
642
631
|
robots: config.robots,
|
|
@@ -663,6 +652,8 @@ export function createDocsServer(config = {}) {
|
|
|
663
652
|
baseUrl: llmsBaseUrl || undefined,
|
|
664
653
|
siteTitle: llmsTitle,
|
|
665
654
|
siteDescription: llmsDesc,
|
|
655
|
+
maxChars: typeof llmsTxtConfig === "object" ? llmsTxtConfig.maxChars : undefined,
|
|
656
|
+
sections: typeof llmsTxtConfig === "object" ? llmsTxtConfig.sections : undefined,
|
|
666
657
|
},
|
|
667
658
|
sitemap: config.sitemap,
|
|
668
659
|
robots: config.robots,
|
|
@@ -715,8 +706,8 @@ export function createDocsServer(config = {}) {
|
|
|
715
706
|
},
|
|
716
707
|
});
|
|
717
708
|
}
|
|
718
|
-
const
|
|
719
|
-
if (
|
|
709
|
+
const llmsRequest = resolveDocsLlmsTxtRequest(event.url, llmsTxtConfig);
|
|
710
|
+
if (llmsRequest) {
|
|
720
711
|
if (!llmsEnabled) {
|
|
721
712
|
return new Response("Not Found", {
|
|
722
713
|
status: 404,
|
|
@@ -726,8 +717,30 @@ export function createDocsServer(config = {}) {
|
|
|
726
717
|
},
|
|
727
718
|
});
|
|
728
719
|
}
|
|
729
|
-
const
|
|
730
|
-
|
|
720
|
+
const selected = selectDocsLlmsTxtContent(getLlmsContent(ctx), llmsRequest);
|
|
721
|
+
if (!selected) {
|
|
722
|
+
return new Response("Not Found", {
|
|
723
|
+
status: 404,
|
|
724
|
+
headers: {
|
|
725
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
726
|
+
"X-Robots-Tag": "noindex",
|
|
727
|
+
},
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
const budgetIssue = getDocsLlmsTxtMaxCharsIssue(selected.label, selected.content, selected.maxChars);
|
|
731
|
+
if (budgetIssue?.mode === "error") {
|
|
732
|
+
return new Response(budgetIssue.message, {
|
|
733
|
+
status: 500,
|
|
734
|
+
headers: {
|
|
735
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
736
|
+
"X-Robots-Tag": "noindex",
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
if (budgetIssue?.mode === "warn") {
|
|
741
|
+
console.warn(`[docs] ${budgetIssue.message}`);
|
|
742
|
+
}
|
|
743
|
+
return new Response(selected.content, {
|
|
731
744
|
headers: {
|
|
732
745
|
"Content-Type": "text/plain; charset=utf-8",
|
|
733
746
|
"Cache-Control": "public, max-age=3600",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.90",
|
|
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.90"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|