@farming-labs/next 0.0.2-beta.2 → 0.0.2-beta.4
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.d.mts +1 -1
- package/dist/config.mjs +15 -19
- package/dist/mdx-plugins/rehype-code.d.mts +2 -0
- package/dist/mdx-plugins/rehype-code.mjs +3 -0
- package/dist/mdx-plugins/rehype-toc.d.mts +2 -0
- package/dist/mdx-plugins/rehype-toc.mjs +3 -0
- package/dist/mdx-plugins/remark-heading.d.mts +2 -0
- package/dist/mdx-plugins/remark-heading.mjs +3 -0
- package/package.json +19 -4
package/dist/config.d.mts
CHANGED
|
@@ -18,6 +18,6 @@ import * as next from "next";
|
|
|
18
18
|
* images: { remotePatterns: [{ hostname: "example.com" }] },
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
|
-
declare function withDocs(nextConfig?: Record<string, unknown>):
|
|
21
|
+
declare function withDocs(nextConfig?: Record<string, unknown>): next.NextConfig;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { withDocs };
|
package/dist/config.mjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import createMDX from "@next/mdx";
|
|
4
|
-
import remarkGfm from "remark-gfm";
|
|
5
|
-
import remarkFrontmatter from "remark-frontmatter";
|
|
6
|
-
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
7
4
|
|
|
8
5
|
//#region src/config.ts
|
|
9
6
|
/**
|
|
@@ -26,7 +23,7 @@ import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
|
26
23
|
const GENERATED_BANNER = "// Auto-generated by @farming-labs/next — do not edit manually.\n";
|
|
27
24
|
const MDX_COMPONENTS_TEMPLATE = `\
|
|
28
25
|
${GENERATED_BANNER}
|
|
29
|
-
import { getMDXComponents } from "@farming-labs/
|
|
26
|
+
import { getMDXComponents } from "@farming-labs/theme/mdx";
|
|
30
27
|
import type { MDXComponents } from "mdx/types";
|
|
31
28
|
import docsConfig from "@/docs.config";
|
|
32
29
|
|
|
@@ -40,16 +37,16 @@ export function useMDXComponents(components?: MDXComponents): MDXComponents {
|
|
|
40
37
|
const DOCS_LAYOUT_TEMPLATE = `\
|
|
41
38
|
${GENERATED_BANNER}
|
|
42
39
|
import docsConfig from "@/docs.config";
|
|
43
|
-
import { createDocsLayout, createDocsMetadata } from "@farming-labs/
|
|
40
|
+
import { createDocsLayout, createDocsMetadata } from "@farming-labs/theme";
|
|
44
41
|
|
|
45
42
|
export const metadata = createDocsMetadata(docsConfig);
|
|
46
43
|
export default createDocsLayout(docsConfig);
|
|
47
44
|
`;
|
|
48
|
-
const
|
|
45
|
+
const DOCS_API_ROUTE_TEMPLATE = `\
|
|
49
46
|
${GENERATED_BANNER}
|
|
50
|
-
import {
|
|
47
|
+
import { createDocsAPI } from "@farming-labs/theme/api";
|
|
51
48
|
|
|
52
|
-
export const { GET } =
|
|
49
|
+
export const { GET, POST } = createDocsAPI();
|
|
53
50
|
|
|
54
51
|
export const revalidate = false;
|
|
55
52
|
`;
|
|
@@ -73,9 +70,8 @@ function readDocsEntry(root) {
|
|
|
73
70
|
}
|
|
74
71
|
return "docs";
|
|
75
72
|
}
|
|
76
|
-
|
|
73
|
+
function withDocs(nextConfig = {}) {
|
|
77
74
|
const root = process.cwd();
|
|
78
|
-
const { remarkHeading, rehypeToc, rehypeCode } = await new Function("specifier", "return import(specifier)")("fumadocs-core/mdx-plugins");
|
|
79
75
|
if (!hasFile(root, "mdx-components")) writeFileSync(join(root, "mdx-components.tsx"), MDX_COMPONENTS_TEMPLATE);
|
|
80
76
|
const layoutDir = join(root, "app", readDocsEntry(root));
|
|
81
77
|
if (existsSync(layoutDir) && !hasFile(layoutDir, "layout")) writeFileSync(join(layoutDir, "layout.tsx"), DOCS_LAYOUT_TEMPLATE);
|
|
@@ -83,21 +79,21 @@ async function withDocs(nextConfig = {}) {
|
|
|
83
79
|
mkdirSync(layoutDir, { recursive: true });
|
|
84
80
|
writeFileSync(join(layoutDir, "layout.tsx"), DOCS_LAYOUT_TEMPLATE);
|
|
85
81
|
}
|
|
86
|
-
const
|
|
87
|
-
if (!hasFile(
|
|
88
|
-
mkdirSync(
|
|
89
|
-
writeFileSync(join(
|
|
82
|
+
const docsApiRouteDir = join(root, "app", "api", "docs");
|
|
83
|
+
if (!hasFile(docsApiRouteDir, "route")) {
|
|
84
|
+
mkdirSync(docsApiRouteDir, { recursive: true });
|
|
85
|
+
writeFileSync(join(docsApiRouteDir, "route.ts"), DOCS_API_ROUTE_TEMPLATE);
|
|
90
86
|
}
|
|
91
87
|
const withMDX = createMDX({
|
|
92
88
|
extension: /\.mdx?$/,
|
|
93
89
|
options: {
|
|
94
90
|
remarkPlugins: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[
|
|
98
|
-
|
|
91
|
+
"remark-gfm",
|
|
92
|
+
"remark-frontmatter",
|
|
93
|
+
["remark-mdx-frontmatter", { name: "metadata" }],
|
|
94
|
+
"@farming-labs/next/mdx-plugins/remark-heading"
|
|
99
95
|
],
|
|
100
|
-
rehypePlugins: [
|
|
96
|
+
rehypePlugins: ["@farming-labs/next/mdx-plugins/rehype-toc", ["@farming-labs/next/mdx-plugins/rehype-code", { themes: {
|
|
101
97
|
dark: "github-dark",
|
|
102
98
|
light: "github-light"
|
|
103
99
|
} }]]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.4",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -15,6 +15,21 @@
|
|
|
15
15
|
"types": "./dist/config.d.mts",
|
|
16
16
|
"import": "./dist/config.mjs",
|
|
17
17
|
"default": "./dist/config.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./mdx-plugins/remark-heading": {
|
|
20
|
+
"types": "./dist/mdx-plugins/remark-heading.d.mts",
|
|
21
|
+
"import": "./dist/mdx-plugins/remark-heading.mjs",
|
|
22
|
+
"default": "./dist/mdx-plugins/remark-heading.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./mdx-plugins/rehype-toc": {
|
|
25
|
+
"types": "./dist/mdx-plugins/rehype-toc.d.mts",
|
|
26
|
+
"import": "./dist/mdx-plugins/rehype-toc.mjs",
|
|
27
|
+
"default": "./dist/mdx-plugins/rehype-toc.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./mdx-plugins/rehype-code": {
|
|
30
|
+
"types": "./dist/mdx-plugins/rehype-code.d.mts",
|
|
31
|
+
"import": "./dist/mdx-plugins/rehype-code.mjs",
|
|
32
|
+
"default": "./dist/mdx-plugins/rehype-code.mjs"
|
|
18
33
|
}
|
|
19
34
|
},
|
|
20
35
|
"files": [
|
|
@@ -43,9 +58,9 @@
|
|
|
43
58
|
"typescript": "^5.9.3"
|
|
44
59
|
},
|
|
45
60
|
"peerDependencies": {
|
|
46
|
-
"next": ">=
|
|
47
|
-
"react": ">=
|
|
48
|
-
"react-dom": ">=
|
|
61
|
+
"next": ">=16.0.0",
|
|
62
|
+
"react": ">=19.2.0",
|
|
63
|
+
"react-dom": ">=19.2.0"
|
|
49
64
|
},
|
|
50
65
|
"scripts": {
|
|
51
66
|
"build": "tsdown",
|