@farming-labs/theme 0.1.79 → 0.1.81
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/docs-api.mjs +15 -6
- package/package.json +2 -2
package/dist/docs-api.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { getNextAppDir } from "./get-app-dir.mjs";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import matter from "gray-matter";
|
|
6
|
-
import { buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsSitemapResponse, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, normalizeDocsRelated, performDocsSearch, renderDocsRelatedMarkdownLines, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLocale, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig } from "@farming-labs/docs";
|
|
6
|
+
import { buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsSitemapResponse, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownNotFound, renderDocsRelatedMarkdownLines, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLocale, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig } from "@farming-labs/docs";
|
|
7
7
|
import { createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
8
8
|
|
|
9
9
|
//#region src/docs-api.ts
|
|
@@ -885,14 +885,16 @@ function resolveMarkdownRequest(entry, url, request) {
|
|
|
885
885
|
requestedPath: pathname.slice(slugPrefix.length, -3),
|
|
886
886
|
delivery: "md_route"
|
|
887
887
|
};
|
|
888
|
-
|
|
888
|
+
const hasSignatureAgent = hasDocsMarkdownSignatureAgent(request);
|
|
889
|
+
if (acceptsMarkdown(request) || hasSignatureAgent) {
|
|
890
|
+
const delivery = hasSignatureAgent ? "signature_agent" : "accept_header";
|
|
889
891
|
if (pathname === normalizedEntry) return {
|
|
890
892
|
requestedPath: "",
|
|
891
|
-
delivery
|
|
893
|
+
delivery
|
|
892
894
|
};
|
|
893
895
|
if (pathname.startsWith(slugPrefix)) return {
|
|
894
896
|
requestedPath: pathname.slice(slugPrefix.length),
|
|
895
|
-
delivery
|
|
897
|
+
delivery
|
|
896
898
|
};
|
|
897
899
|
}
|
|
898
900
|
return null;
|
|
@@ -1769,6 +1771,7 @@ function createDocsAPI(options) {
|
|
|
1769
1771
|
const markdownRequest = resolveMarkdownRequest(entry, url, request);
|
|
1770
1772
|
if (markdownRequest) {
|
|
1771
1773
|
const document = await getMarkdownDocument(ctx, markdownRequest.requestedPath);
|
|
1774
|
+
const varyHeader = getDocsMarkdownVaryHeader(request);
|
|
1772
1775
|
if (!document) {
|
|
1773
1776
|
await emitDocsAnalyticsEvent(analytics, {
|
|
1774
1777
|
type: "agent_read",
|
|
@@ -1794,10 +1797,15 @@ function createDocsAPI(options) {
|
|
|
1794
1797
|
found: false
|
|
1795
1798
|
}
|
|
1796
1799
|
});
|
|
1797
|
-
return new Response(
|
|
1800
|
+
return new Response(renderDocsMarkdownNotFound({
|
|
1801
|
+
entry,
|
|
1802
|
+
requestedPath: markdownRequest.requestedPath,
|
|
1803
|
+
sitemap: sitemapConfig
|
|
1804
|
+
}), {
|
|
1798
1805
|
status: 404,
|
|
1799
1806
|
headers: {
|
|
1800
|
-
"Content-Type": "text/
|
|
1807
|
+
"Content-Type": "text/markdown; charset=utf-8",
|
|
1808
|
+
...varyHeader ? { Vary: varyHeader } : {},
|
|
1801
1809
|
"X-Robots-Tag": "noindex"
|
|
1802
1810
|
}
|
|
1803
1811
|
});
|
|
@@ -1831,6 +1839,7 @@ function createDocsAPI(options) {
|
|
|
1831
1839
|
return new Response(document, { headers: {
|
|
1832
1840
|
"Content-Type": "text/markdown; charset=utf-8",
|
|
1833
1841
|
"Cache-Control": "public, max-age=0, s-maxage=3600",
|
|
1842
|
+
...varyHeader ? { Vary: varyHeader } : {},
|
|
1834
1843
|
"X-Robots-Tag": "noindex"
|
|
1835
1844
|
} });
|
|
1836
1845
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.81",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsdown": "^0.20.3",
|
|
140
140
|
"typescript": "^5.9.3",
|
|
141
141
|
"vitest": "^3.2.4",
|
|
142
|
-
"@farming-labs/docs": "0.1.
|
|
142
|
+
"@farming-labs/docs": "0.1.81"
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"@farming-labs/docs": ">=0.0.1",
|