@farming-labs/svelte 0.2.52 → 0.2.53
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 +6 -1
- package/dist/content.js +8 -1
- package/dist/server.js +24 -48
- 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, type SidebarFolderIndexBehavior } from "@farming-labs/docs";
|
|
8
|
+
import { type OrderingItem, type PageAgentFrontmatter, type ResolvedDocsRelatedLink, type SidebarFolderIndexBehavior } from "@farming-labs/docs";
|
|
9
9
|
export interface PageNode {
|
|
10
10
|
type: "page";
|
|
11
11
|
name: string;
|
|
@@ -32,9 +32,14 @@ export interface ContentPage {
|
|
|
32
32
|
title: string;
|
|
33
33
|
description?: string;
|
|
34
34
|
related?: ResolvedDocsRelatedLink[];
|
|
35
|
+
agent?: PageAgentFrontmatter;
|
|
35
36
|
icon?: string;
|
|
36
37
|
sourcePath?: string;
|
|
37
38
|
lastModified?: string;
|
|
39
|
+
locale?: string;
|
|
40
|
+
framework?: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
tags?: string[];
|
|
38
43
|
content: string;
|
|
39
44
|
rawContent: string;
|
|
40
45
|
agentContent?: string;
|
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, resolvePageSidebarFolderIndexBehavior, } from "@farming-labs/docs";
|
|
11
|
+
import { normalizeDocsRelated, normalizePageAgentFrontmatter, 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:
|
|
@@ -52,9 +52,16 @@ export function loadDocsContent(contentDir, entry = "docs") {
|
|
|
52
52
|
title,
|
|
53
53
|
description: data.description,
|
|
54
54
|
...(related.length > 0 ? { related } : {}),
|
|
55
|
+
agent: normalizePageAgentFrontmatter(data.agent),
|
|
55
56
|
icon: data.icon,
|
|
56
57
|
sourcePath: full.replace(/\\/g, "/"),
|
|
57
58
|
lastModified: stat.mtime.toISOString(),
|
|
59
|
+
locale: typeof data.locale === "string" ? data.locale : undefined,
|
|
60
|
+
framework: typeof data.framework === "string" ? data.framework : undefined,
|
|
61
|
+
version: typeof data.version === "string" ? data.version : undefined,
|
|
62
|
+
tags: Array.isArray(data.tags)
|
|
63
|
+
? data.tags.filter((tag) => typeof tag === "string")
|
|
64
|
+
: undefined,
|
|
58
65
|
content: stripMarkdown(humanRawContent),
|
|
59
66
|
rawContent: humanRawContent,
|
|
60
67
|
...(pageAgentRawContent !== humanRawContent
|
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, buildDocsConfigMap, buildDocsDiagnostics, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue,
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, isDocsAgentDiscoveryRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, } from "@farming-labs/docs";
|
|
34
34
|
import { buildApiReferenceOpenApiDocumentAsync, createDocsCloudAskAIResponse, createDocsMcpHttpHandler, isDocsCloudAskAIProvider, readDocsSitemapManifest, resolveApiReferenceConfig, resolveDocsMcpConfig, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
@@ -336,7 +336,14 @@ function searchIndexFromMap(contentMap, dirPrefix, entry) {
|
|
|
336
336
|
title,
|
|
337
337
|
description: data.description,
|
|
338
338
|
...(related.length > 0 ? { related } : {}),
|
|
339
|
+
agent: normalizePageAgentFrontmatter(data.agent),
|
|
339
340
|
icon: data.icon,
|
|
341
|
+
locale: typeof data.locale === "string" ? data.locale : undefined,
|
|
342
|
+
framework: typeof data.framework === "string" ? data.framework : undefined,
|
|
343
|
+
version: typeof data.version === "string" ? data.version : undefined,
|
|
344
|
+
tags: Array.isArray(data.tags)
|
|
345
|
+
? data.tags.filter((tag) => typeof tag === "string")
|
|
346
|
+
: undefined,
|
|
340
347
|
content: stripMarkdownText(humanRawContent),
|
|
341
348
|
rawContent: humanRawContent,
|
|
342
349
|
...(pageAgentRawContent !== humanRawContent
|
|
@@ -585,6 +592,7 @@ export function createDocsServer(config = {}) {
|
|
|
585
592
|
baseUrl: resolveDocsMetadataBaseUrl(config),
|
|
586
593
|
entry,
|
|
587
594
|
dateModified: lastModifiedIso,
|
|
595
|
+
agent: normalizePageAgentFrontmatter(data.agent),
|
|
588
596
|
});
|
|
589
597
|
return {
|
|
590
598
|
tree,
|
|
@@ -682,9 +690,14 @@ export function createDocsServer(config = {}) {
|
|
|
682
690
|
return locale;
|
|
683
691
|
return i18n.defaultLocale;
|
|
684
692
|
}
|
|
685
|
-
function
|
|
693
|
+
function getMarkdownRepresentation(ctx, requestedPath, origin) {
|
|
686
694
|
const page = findDocsMarkdownPage(entry, getSearchIndex(ctx), requestedPath);
|
|
687
|
-
return page
|
|
695
|
+
return page
|
|
696
|
+
? {
|
|
697
|
+
document: renderDocsMarkdownDocument(page, { origin, sitemap: config.sitemap }),
|
|
698
|
+
lastModified: page.agentRawContent === undefined ? page.lastModified : undefined,
|
|
699
|
+
}
|
|
700
|
+
: null;
|
|
688
701
|
}
|
|
689
702
|
// ─── GET /api/docs?query=… | ?format=llms | ?format=llms-full ──
|
|
690
703
|
async function GET(event) {
|
|
@@ -870,54 +883,17 @@ export function createDocsServer(config = {}) {
|
|
|
870
883
|
const markdownRequest = resolveDocsMarkdownRequest(entry, event.url, event.request);
|
|
871
884
|
if (markdownRequest) {
|
|
872
885
|
const markdownOrigin = markdownMetadataBaseUrl || event.url.origin;
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
886
|
+
const representation = getMarkdownRepresentation(ctx, markdownRequest.requestedPath, markdownOrigin);
|
|
887
|
+
return createDocsMarkdownResponse({
|
|
888
|
+
request: event.request,
|
|
889
|
+
document: representation?.document ?? null,
|
|
877
890
|
entry,
|
|
878
891
|
requestedPath: markdownRequest.requestedPath,
|
|
892
|
+
origin: markdownOrigin,
|
|
879
893
|
locale: ctx.locale,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
entry,
|
|
884
|
-
requestedPath: markdownRequest.requestedPath,
|
|
885
|
-
pages: getSearchIndex(ctx),
|
|
886
|
-
sitemap: config.sitemap,
|
|
887
|
-
});
|
|
888
|
-
if (recovery.redirect) {
|
|
889
|
-
return new Response(null, {
|
|
890
|
-
status: 307,
|
|
891
|
-
headers: {
|
|
892
|
-
Location: new URL(recovery.redirect.markdownUrl, event.url.origin).toString(),
|
|
893
|
-
...(varyHeader ? { Vary: varyHeader } : {}),
|
|
894
|
-
"X-Robots-Tag": "noindex",
|
|
895
|
-
},
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
return new Response(renderDocsMarkdownNotFound({
|
|
899
|
-
entry,
|
|
900
|
-
requestedPath: markdownRequest.requestedPath,
|
|
901
|
-
origin: markdownOrigin,
|
|
902
|
-
pages: getSearchIndex(ctx),
|
|
903
|
-
sitemap: config.sitemap,
|
|
904
|
-
}), {
|
|
905
|
-
status: 200,
|
|
906
|
-
headers: {
|
|
907
|
-
"Content-Type": "text/markdown; charset=utf-8",
|
|
908
|
-
...(varyHeader ? { Vary: varyHeader } : {}),
|
|
909
|
-
"X-Robots-Tag": "noindex",
|
|
910
|
-
},
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
return new Response(document, {
|
|
914
|
-
headers: {
|
|
915
|
-
"Content-Type": "text/markdown; charset=utf-8",
|
|
916
|
-
"Cache-Control": "public, max-age=0, s-maxage=3600",
|
|
917
|
-
Link: canonicalLinkHeader,
|
|
918
|
-
...(varyHeader ? { Vary: varyHeader } : {}),
|
|
919
|
-
"X-Robots-Tag": "noindex",
|
|
920
|
-
},
|
|
894
|
+
lastModified: representation?.lastModified,
|
|
895
|
+
pages: getSearchIndex(ctx),
|
|
896
|
+
sitemap: config.sitemap,
|
|
921
897
|
});
|
|
922
898
|
}
|
|
923
899
|
const llmsRequest = resolveDocsLlmsTxtRequest(event.url, llmsTxtConfig, entry);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.53",
|
|
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.2.
|
|
59
|
+
"@farming-labs/docs": "0.2.53"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|