@farming-labs/theme 0.1.18 → 0.1.20
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 +13 -3
- package/package.json +2 -2
package/dist/docs-api.mjs
CHANGED
|
@@ -444,6 +444,15 @@ function findDocsMcpPage(entry, pages, requestedPath) {
|
|
|
444
444
|
for (const page of pages) if (normalizePathSegment(page.slug) === normalizedSlug) return page;
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
|
+
function resolveMarkdownRequest(entry, url) {
|
|
448
|
+
if (url.searchParams.get("format")?.trim() === "markdown") return { requestedPath: url.searchParams.get("path")?.trim() ?? "" };
|
|
449
|
+
const pathname = normalizeUrlPath(url.pathname);
|
|
450
|
+
const normalizedEntry = `/${normalizePathSegment(entry)}`;
|
|
451
|
+
if (pathname === `${normalizedEntry}.md`) return { requestedPath: "" };
|
|
452
|
+
const slugPrefix = `${normalizedEntry}/`;
|
|
453
|
+
if (pathname.startsWith(slugPrefix) && pathname.endsWith(".md")) return { requestedPath: pathname.slice(slugPrefix.length, -3) };
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
447
456
|
function renderMarkdownDocument(page) {
|
|
448
457
|
if ("agentRawContent" in page && page.agentRawContent !== void 0) return page.agentRawContent;
|
|
449
458
|
const lines = [`# ${page.title}`, `URL: ${page.url}`];
|
|
@@ -722,9 +731,9 @@ function createDocsAPI(options) {
|
|
|
722
731
|
async GET(request) {
|
|
723
732
|
const ctx = resolveContextFromRequest(request);
|
|
724
733
|
const url = new URL(request.url);
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
const document = await getMarkdownDocument(ctx,
|
|
734
|
+
const markdownRequest = resolveMarkdownRequest(entry, url);
|
|
735
|
+
if (markdownRequest) {
|
|
736
|
+
const document = await getMarkdownDocument(ctx, markdownRequest.requestedPath);
|
|
728
737
|
if (!document) return new Response("Not Found", {
|
|
729
738
|
status: 404,
|
|
730
739
|
headers: {
|
|
@@ -738,6 +747,7 @@ function createDocsAPI(options) {
|
|
|
738
747
|
"X-Robots-Tag": "noindex"
|
|
739
748
|
} });
|
|
740
749
|
}
|
|
750
|
+
const format = url.searchParams.get("format");
|
|
741
751
|
if (format === "llms") return new Response(getLlmsContent(ctx).llmsTxt, { headers: {
|
|
742
752
|
"Content-Type": "text/plain; charset=utf-8",
|
|
743
753
|
"Cache-Control": "public, max-age=3600"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"tsdown": "^0.20.3",
|
|
134
134
|
"typescript": "^5.9.3",
|
|
135
135
|
"vitest": "^3.2.4",
|
|
136
|
-
"@farming-labs/docs": "0.1.
|
|
136
|
+
"@farming-labs/docs": "0.1.20"
|
|
137
137
|
},
|
|
138
138
|
"peerDependencies": {
|
|
139
139
|
"@farming-labs/docs": ">=0.0.1",
|