@farming-labs/next 0.1.17 → 0.1.18
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/config.mjs +4 -39
- package/package.json +3 -3
package/dist/config.mjs
CHANGED
|
@@ -95,34 +95,6 @@ export const { GET, POST, DELETE } = createDocsMCPAPI({
|
|
|
95
95
|
mcp: docsConfig.mcp,
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
export const revalidate = false;
|
|
99
|
-
`;
|
|
100
|
-
const DOCS_MARKDOWN_ROUTE_TEMPLATE = `\
|
|
101
|
-
${GENERATED_BANNER}
|
|
102
|
-
import docsConfig from "@/docs.config";
|
|
103
|
-
import { createDocsAPI } from "@farming-labs/next/api";
|
|
104
|
-
|
|
105
|
-
const handlers = createDocsAPI({
|
|
106
|
-
entry: docsConfig.entry,
|
|
107
|
-
contentDir: docsConfig.contentDir,
|
|
108
|
-
i18n: docsConfig.i18n,
|
|
109
|
-
changelog: docsConfig.changelog,
|
|
110
|
-
search: docsConfig.search,
|
|
111
|
-
ai: docsConfig.ai,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
export async function GET(
|
|
115
|
-
request: Request,
|
|
116
|
-
{ params }: { params: Promise<{ slug?: string[] }> },
|
|
117
|
-
) {
|
|
118
|
-
const { slug = [] } = await params;
|
|
119
|
-
const url = new URL(request.url);
|
|
120
|
-
url.searchParams.set("format", "markdown");
|
|
121
|
-
if (slug.length > 0) url.searchParams.set("path", slug.join("/"));
|
|
122
|
-
else url.searchParams.delete("path");
|
|
123
|
-
return handlers.GET(new Request(url, { headers: request.headers }));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
98
|
export const revalidate = false;
|
|
127
99
|
`;
|
|
128
100
|
const API_REFERENCE_ROUTE_TEMPLATE = `\
|
|
@@ -662,13 +634,13 @@ function readMcpConfig(root) {
|
|
|
662
634
|
};
|
|
663
635
|
} catch {
|
|
664
636
|
return {
|
|
665
|
-
enabled:
|
|
637
|
+
enabled: true,
|
|
666
638
|
route: "/api/docs/mcp"
|
|
667
639
|
};
|
|
668
640
|
}
|
|
669
641
|
}
|
|
670
642
|
return {
|
|
671
|
-
enabled:
|
|
643
|
+
enabled: true,
|
|
672
644
|
route: "/api/docs/mcp"
|
|
673
645
|
};
|
|
674
646
|
}
|
|
@@ -680,10 +652,10 @@ function buildDocsMarkdownRewrites(entry) {
|
|
|
680
652
|
const normalizedEntry = entry.replace(/^\/+|\/+$/g, "") || "docs";
|
|
681
653
|
return [{
|
|
682
654
|
source: `/${normalizedEntry}.md`,
|
|
683
|
-
destination: "/api/docs
|
|
655
|
+
destination: "/api/docs?format=markdown"
|
|
684
656
|
}, {
|
|
685
657
|
source: `/${normalizedEntry}/:slug*.md`,
|
|
686
|
-
destination: "/api/docs
|
|
658
|
+
destination: "/api/docs?format=markdown&path=:slug*"
|
|
687
659
|
}];
|
|
688
660
|
}
|
|
689
661
|
function dedupeRewrites(rewrites) {
|
|
@@ -728,11 +700,6 @@ function withDocs(nextConfig = {}) {
|
|
|
728
700
|
mkdirSync(docsApiRouteDir, { recursive: true });
|
|
729
701
|
writeFileSync(join(docsApiRouteDir, "route.ts"), DOCS_API_ROUTE_TEMPLATE);
|
|
730
702
|
}
|
|
731
|
-
const docsMarkdownRouteDir = join(root, appDir, "api", "docs", "markdown", "[[...slug]]");
|
|
732
|
-
if (!isStaticExport && (!hasFile(docsMarkdownRouteDir, "route") || isManagedGeneratedFile(join(docsMarkdownRouteDir, "route.ts")))) {
|
|
733
|
-
mkdirSync(docsMarkdownRouteDir, { recursive: true });
|
|
734
|
-
writeFileSync(join(docsMarkdownRouteDir, "route.ts"), DOCS_MARKDOWN_ROUTE_TEMPLATE);
|
|
735
|
-
}
|
|
736
703
|
const mcp = readMcpConfig(root);
|
|
737
704
|
const docsMcpRouteDir = join(root, appDir, "api", "docs", "mcp");
|
|
738
705
|
if (mcp.enabled && mcp.route === "/api/docs/mcp" && !isStaticExport && !hasFile(docsMcpRouteDir, "route")) {
|
|
@@ -892,8 +859,6 @@ function withDocs(nextConfig = {}) {
|
|
|
892
859
|
nextConfig.outputFileTracingIncludes = {
|
|
893
860
|
...existingTracingIncludes,
|
|
894
861
|
"/api/docs": [...new Set([...existingTracingIncludes["/api/docs"] ?? [], docsTraceGlob])],
|
|
895
|
-
"/api/docs/markdown": [...new Set([...existingTracingIncludes["/api/docs/markdown"] ?? [], docsTraceGlob])],
|
|
896
|
-
"/api/docs/markdown/[[...slug]]": [...new Set([...existingTracingIncludes["/api/docs/markdown/[[...slug]]"] ?? [], docsTraceGlob])],
|
|
897
862
|
"/api/docs/mcp": [...new Set([...existingTracingIncludes["/api/docs/mcp"] ?? [], docsTraceGlob])]
|
|
898
863
|
};
|
|
899
864
|
return withMDX(nextConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"tsdown": "^0.20.3",
|
|
96
96
|
"typescript": "^5.9.3",
|
|
97
97
|
"vitest": "^3.2.4",
|
|
98
|
-
"@farming-labs/docs": "0.1.
|
|
99
|
-
"@farming-labs/theme": "0.1.
|
|
98
|
+
"@farming-labs/docs": "0.1.18",
|
|
99
|
+
"@farming-labs/theme": "0.1.18"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"@farming-labs/docs": ">=0.0.1",
|