@farming-labs/next 0.1.78 → 0.1.80
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 +76 -1
- package/package.json +3 -3
package/dist/config.mjs
CHANGED
|
@@ -92,6 +92,44 @@ export const { GET, POST } = createDocsAPI({
|
|
|
92
92
|
ai: docsConfig.ai,
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
export const revalidate = false;
|
|
96
|
+
`;
|
|
97
|
+
const DOCS_MARKDOWN_ROUTE_TEMPLATE = `\
|
|
98
|
+
${GENERATED_BANNER}
|
|
99
|
+
import docsConfig from "@/docs.config";
|
|
100
|
+
import { createDocsAPI } from "@farming-labs/next/api";
|
|
101
|
+
|
|
102
|
+
const docsApi = createDocsAPI({
|
|
103
|
+
entry: docsConfig.entry,
|
|
104
|
+
contentDir: docsConfig.contentDir,
|
|
105
|
+
i18n: docsConfig.i18n,
|
|
106
|
+
changelog: docsConfig.changelog,
|
|
107
|
+
feedback: docsConfig.feedback,
|
|
108
|
+
mcp: docsConfig.mcp,
|
|
109
|
+
sitemap: docsConfig.sitemap,
|
|
110
|
+
search: docsConfig.search,
|
|
111
|
+
analytics: docsConfig.analytics,
|
|
112
|
+
observability: docsConfig.observability,
|
|
113
|
+
ai: docsConfig.ai,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
type MarkdownRouteContext = {
|
|
117
|
+
params?: Promise<{ slug?: string[] }> | { slug?: string[] };
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export async function GET(request: Request, context: MarkdownRouteContext = {}) {
|
|
121
|
+
const params = context.params ? await context.params : undefined;
|
|
122
|
+
const slug = params?.slug?.join("/") ?? "";
|
|
123
|
+
const url = new URL(request.url);
|
|
124
|
+
|
|
125
|
+
url.pathname = "/api/docs";
|
|
126
|
+
url.search = "";
|
|
127
|
+
url.searchParams.set("format", "markdown");
|
|
128
|
+
if (slug) url.searchParams.set("path", slug);
|
|
129
|
+
|
|
130
|
+
return docsApi.GET(new Request(url.toString(), request));
|
|
131
|
+
}
|
|
132
|
+
|
|
95
133
|
export const revalidate = false;
|
|
96
134
|
`;
|
|
97
135
|
const DOCS_MCP_ROUTE_TEMPLATE = `\
|
|
@@ -816,6 +854,10 @@ function buildDocsMarkdownRewrites(entry) {
|
|
|
816
854
|
key: "accept",
|
|
817
855
|
value: MARKDOWN_ACCEPT_HEADER_VALUE
|
|
818
856
|
};
|
|
857
|
+
const markdownSignatureAgentHeader = {
|
|
858
|
+
type: "header",
|
|
859
|
+
key: "signature-agent"
|
|
860
|
+
};
|
|
819
861
|
return [
|
|
820
862
|
{
|
|
821
863
|
source: `/${normalizedEntry}.md`,
|
|
@@ -834,6 +876,16 @@ function buildDocsMarkdownRewrites(entry) {
|
|
|
834
876
|
source: `/${normalizedEntry}/:slug*`,
|
|
835
877
|
has: [markdownAcceptHeader],
|
|
836
878
|
destination: "/api/docs?format=markdown&path=:slug*"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
source: `/${normalizedEntry}`,
|
|
882
|
+
has: [markdownSignatureAgentHeader],
|
|
883
|
+
destination: "/api/docs/markdown"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
source: `/${normalizedEntry}/:slug*`,
|
|
887
|
+
has: [markdownSignatureAgentHeader],
|
|
888
|
+
destination: "/api/docs/markdown/:slug*"
|
|
837
889
|
}
|
|
838
890
|
];
|
|
839
891
|
}
|
|
@@ -921,7 +973,12 @@ function dedupeRewrites(rewrites) {
|
|
|
921
973
|
const seen = /* @__PURE__ */ new Set();
|
|
922
974
|
const result = [];
|
|
923
975
|
for (const rewrite of rewrites) {
|
|
924
|
-
const key =
|
|
976
|
+
const key = JSON.stringify({
|
|
977
|
+
source: rewrite.source,
|
|
978
|
+
destination: rewrite.destination,
|
|
979
|
+
has: rewrite.has ?? [],
|
|
980
|
+
missing: rewrite.missing ?? []
|
|
981
|
+
});
|
|
925
982
|
if (seen.has(key)) continue;
|
|
926
983
|
seen.add(key);
|
|
927
984
|
result.push(rewrite);
|
|
@@ -1074,6 +1131,12 @@ function withDocs(nextConfig = {}) {
|
|
|
1074
1131
|
mkdirSync(docsApiRouteDir, { recursive: true });
|
|
1075
1132
|
writeFileSync(join(docsApiRouteDir, "route.ts"), DOCS_API_ROUTE_TEMPLATE);
|
|
1076
1133
|
}
|
|
1134
|
+
const docsMarkdownRouteDir = join(root, appDir, "api", "docs", "markdown", "[[...slug]]");
|
|
1135
|
+
const docsMarkdownRoutePath = join(docsMarkdownRouteDir, "route.ts");
|
|
1136
|
+
if (!isStaticExport && (!hasFile(docsMarkdownRouteDir, "route") || isManagedGeneratedFile(docsMarkdownRoutePath))) {
|
|
1137
|
+
mkdirSync(docsMarkdownRouteDir, { recursive: true });
|
|
1138
|
+
writeFileSync(docsMarkdownRoutePath, DOCS_MARKDOWN_ROUTE_TEMPLATE);
|
|
1139
|
+
}
|
|
1077
1140
|
const mcp = readMcpConfig(root);
|
|
1078
1141
|
const sitemap = readSitemapConfig(root);
|
|
1079
1142
|
const docsMcpRouteDir = join(root, appDir, "api", "docs", "mcp");
|
|
@@ -1256,6 +1319,18 @@ function withDocs(nextConfig = {}) {
|
|
|
1256
1319
|
skillTraceFile,
|
|
1257
1320
|
sitemapManifestTraceFile
|
|
1258
1321
|
])],
|
|
1322
|
+
"/api/docs/markdown": [...new Set([
|
|
1323
|
+
...existingTracingIncludes["/api/docs/markdown"] ?? [],
|
|
1324
|
+
docsTraceGlob,
|
|
1325
|
+
skillTraceFile,
|
|
1326
|
+
sitemapManifestTraceFile
|
|
1327
|
+
])],
|
|
1328
|
+
"/api/docs/markdown/:path*": [...new Set([
|
|
1329
|
+
...existingTracingIncludes["/api/docs/markdown/:path*"] ?? [],
|
|
1330
|
+
docsTraceGlob,
|
|
1331
|
+
skillTraceFile,
|
|
1332
|
+
sitemapManifestTraceFile
|
|
1333
|
+
])],
|
|
1259
1334
|
[DEFAULT_MCP_ROUTE]: [...new Set([...existingTracingIncludes[DEFAULT_MCP_ROUTE] ?? [], docsTraceGlob])]
|
|
1260
1335
|
};
|
|
1261
1336
|
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.80",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"tsdown": "^0.20.3",
|
|
101
101
|
"typescript": "^5.9.3",
|
|
102
102
|
"vitest": "^3.2.4",
|
|
103
|
-
"@farming-labs/
|
|
104
|
-
"@farming-labs/
|
|
103
|
+
"@farming-labs/theme": "0.1.80",
|
|
104
|
+
"@farming-labs/docs": "0.1.80"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"@farming-labs/docs": ">=0.0.1",
|