mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
MDX & MDX Remote: Support preset: minimal to disable Fumadocs specific defaults
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@fumadocs/mdx-remote': minor
|
||||
'fumadocs-mdx': minor
|
||||
---
|
||||
|
||||
Support `preset: minimal` to disable Fumadocs specific defaults
|
||||
Generated
+1
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/packages/create-app/dist/my-app" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+12
-12
@@ -20,9 +20,9 @@
|
||||
"@radix-ui/react-dialog": "^1.1.14",
|
||||
"@radix-ui/react-hover-card": "^1.1.14",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@shikijs/rehype": "^3.8.0",
|
||||
"@shikijs/transformers": "^3.8.0",
|
||||
"ai": "^4.3.18",
|
||||
"@shikijs/rehype": "^3.8.1",
|
||||
"@shikijs/transformers": "^3.8.1",
|
||||
"ai": "^4.3.19",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"feed": "^5.1.0",
|
||||
"fumadocs-core": "workspace:*",
|
||||
@@ -35,11 +35,11 @@
|
||||
"hast-util-to-jsx-runtime": "^2.3.6",
|
||||
"katex": "^0.16.22",
|
||||
"lucide-react": "^0.525.0",
|
||||
"mermaid": "^11.8.1",
|
||||
"next": "15.4.1",
|
||||
"mermaid": "^11.9.0",
|
||||
"next": "15.4.2",
|
||||
"next-themes": "^0.4.6",
|
||||
"octokit": "^5.0.3",
|
||||
"oxc-transform": "^0.77.0",
|
||||
"oxc-transform": "^0.77.2",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"rehype-katex": "^7.0.1",
|
||||
@@ -49,7 +49,7 @@
|
||||
"remark-mdx": "^3.1.0",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"twoslash": "^0.3.2",
|
||||
"unist-util-visit": "^5.0.0",
|
||||
@@ -57,16 +57,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fumadocs/cli": "workspace:*",
|
||||
"@next/bundle-analyzer": "15.4.1",
|
||||
"@next/env": "15.4.1",
|
||||
"@next/eslint-plugin-next": "15.4.1",
|
||||
"@next/bundle-analyzer": "15.4.2",
|
||||
"@next/env": "15.4.2",
|
||||
"@next/eslint-plugin-next": "15.4.2",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"algoliasearch": "5.32.0",
|
||||
"algoliasearch": "5.34.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"gray-matter": "^4.0.3",
|
||||
"next-validate-link": "^1.5.2",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"@fumadocs/content-collections": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "^15.4.1",
|
||||
"next": "^15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineDocs, defineConfig } from 'fumadocs-mdx/config';
|
||||
import { defineConfig, defineDocs } from 'fumadocs-mdx/config';
|
||||
|
||||
export const docs = defineDocs({
|
||||
dir: 'content/docs',
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-openapi": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"shiki": "^3.8.0"
|
||||
"shiki": "^3.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-python": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"postcss": "^8.5.6",
|
||||
|
||||
@@ -11,25 +11,25 @@
|
||||
"dependencies": {
|
||||
"@fumadocs/mdx-remote": "workspace:*",
|
||||
"@orama/tokenizers": "^3.1.11",
|
||||
"@react-router/node": "^7.6.3",
|
||||
"@react-router/serve": "^7.6.3",
|
||||
"@react-router/node": "^7.7.0",
|
||||
"@react-router/serve": "^7.7.0",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"gray-matter": "^4.0.3",
|
||||
"isbot": "^5.1.27",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-router": "^7.6.3"
|
||||
"react-router": "^7.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-router/dev": "^7.6.3",
|
||||
"@react-router/dev": "^7.7.0",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@types/node": "^24.0.13",
|
||||
"@types/node": "^24.0.15",
|
||||
"@types/react": "^19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^7.0.4",
|
||||
"vite": "^7.0.5",
|
||||
"vite-tsconfig-paths": "^5.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@
|
||||
"typecheck": "react-router typegen && tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-router/node": "^7.6.3",
|
||||
"@react-router/serve": "^7.6.3",
|
||||
"@react-router/node": "^7.7.0",
|
||||
"@react-router/serve": "^7.7.0",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-mdx": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"isbot": "^5.1.28",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-router": "^7.6.3"
|
||||
"react-router": "^7.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-router/dev": "^7.6.3",
|
||||
"@react-router/dev": "^7.7.0",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@types/node": "^24.0.13",
|
||||
"@types/node": "^24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"react-router-devtools": "^5.0.6",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^7.0.4",
|
||||
"vite": "^7.0.5",
|
||||
"vite-tsconfig-paths": "^5.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"@fumadocs/mdx-remote": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"tinyglobby": "^0.2.14"
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@fumadocs/mdx-remote": "workspace:*",
|
||||
"@tanstack/react-router": "^1.127.8",
|
||||
"@tanstack/react-router-devtools": "^1.127.8",
|
||||
"@tanstack/react-start": "^1.127.8",
|
||||
"@tanstack/react-router": "^1.128.8",
|
||||
"@tanstack/react-router-devtools": "^1.128.8",
|
||||
"@tanstack/react-start": "^1.128.8",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
"gray-matter": "^4.0.3",
|
||||
@@ -20,12 +20,12 @@
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"vite": "^7.0.4",
|
||||
"vite": "^7.0.5",
|
||||
"zod": "^4.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@types/node": "^24.0.13",
|
||||
"@types/node": "^24.0.15",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"tailwindcss": "^4.1.11",
|
||||
|
||||
+2
-2
@@ -23,12 +23,12 @@
|
||||
"eslint": "^9.31.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "5.2.0",
|
||||
"eslint-plugin-tailwindcss": "^3.18.0",
|
||||
"eslint-plugin-tailwindcss": "^3.18.2",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-plugin-astro": "^0.14.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"tsup": "8.5.0",
|
||||
"turbo": "2.5.4",
|
||||
"turbo": "2.5.5",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.37.0",
|
||||
"vitest": "^3.2.4"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"ts-morph": "^26.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"tsconfig": "workspace:*",
|
||||
"tsx": "^4.20.3"
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"devDependencies": {
|
||||
"@content-collections/core": "^0.10.0",
|
||||
"@content-collections/mdx": "^0.2.2",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"tsconfig": "workspace:*",
|
||||
|
||||
@@ -94,8 +94,8 @@
|
||||
"dependencies": {
|
||||
"@formatjs/intl-localematcher": "^0.6.1",
|
||||
"@orama/orama": "^3.1.11",
|
||||
"@shikijs/rehype": "^3.8.0",
|
||||
"@shikijs/transformers": "^3.8.0",
|
||||
"@shikijs/rehype": "^3.8.1",
|
||||
"@shikijs/transformers": "^3.8.1",
|
||||
"github-slugger": "^2.0.0",
|
||||
"hast-util-to-estree": "^3.1.3",
|
||||
"hast-util-to-jsx-runtime": "^2.3.6",
|
||||
@@ -107,26 +107,26 @@
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdx-js/mdx": "^3.1.0",
|
||||
"@oramacloud/client": "^2.1.4",
|
||||
"@tanstack/react-router": "^1.127.8",
|
||||
"@tanstack/react-router": "^1.128.8",
|
||||
"@types/estree-jsx": "^1.0.5",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/negotiator": "^0.6.4",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"algoliasearch": "5.32.0",
|
||||
"algoliasearch": "5.34.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"mdast-util-mdx-jsx": "^3.2.0",
|
||||
"mdast-util-mdxjs-esm": "^2.0.1",
|
||||
"next": "^15.4.1",
|
||||
"react-router": "^7.6.3",
|
||||
"next": "^15.4.2",
|
||||
"react-router": "^7.7.0",
|
||||
"remark-mdx": "^3.1.0",
|
||||
"tsconfig": "workspace:*",
|
||||
"typescript": "^5.8.3",
|
||||
|
||||
@@ -8,32 +8,32 @@
|
||||
"@content-collections/core": "^0.10.0",
|
||||
"@content-collections/mdx": "^0.2.2",
|
||||
"@content-collections/next": "^0.2.6",
|
||||
"@react-router/dev": "^7.6.3",
|
||||
"@react-router/node": "^7.6.3",
|
||||
"@react-router/serve": "^7.6.3",
|
||||
"@react-router/dev": "^7.7.0",
|
||||
"@react-router/node": "^7.7.0",
|
||||
"@react-router/serve": "^7.7.0",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@tanstack/react-router": "^1.127.8",
|
||||
"@tanstack/react-start": "^1.127.8",
|
||||
"@tanstack/react-router": "^1.128.8",
|
||||
"@tanstack/react-start": "^1.128.8",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"gray-matter": "^4.0.3",
|
||||
"isbot": "^5.1.28",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"postcss": "^8.5.6",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-router": "^7.6.3",
|
||||
"react-router": "^7.7.0",
|
||||
"react-router-devtools": "^5.0.6",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"typescript": "^5.8.3",
|
||||
"vinxi": "^0.5.8",
|
||||
"vite": "^7.0.4",
|
||||
"vite": "^7.0.5",
|
||||
"vite-tsconfig-paths": "^5.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cross-spawn": "^6.0.6",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"tsconfig": "workspace:*"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"estree-util-to-js": "^2.0.0",
|
||||
"estree-util-value-to-estree": "^3.4.0",
|
||||
"npm-to-yarn": "^3.0.1",
|
||||
"oxc-transform": "^0.77.0",
|
||||
"oxc-transform": "^0.77.2",
|
||||
"unist-util-visit": "^5.0.0",
|
||||
"zod": "^4.0.5"
|
||||
},
|
||||
@@ -49,7 +49,7 @@
|
||||
"@types/estree": "^1.0.8",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"mdast-util-mdx-jsx": "^3.2.0",
|
||||
"remark": "^15.0.0",
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
|
||||
@@ -7,10 +7,11 @@ import type { TableOfContents } from 'fumadocs-core/server';
|
||||
import { executeMdx, type MdxContent } from '@/render';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
export type MDXOptions = Omit<
|
||||
export type FumadocsPresetOptions = Omit<
|
||||
CompileOptions,
|
||||
'remarkPlugins' | 'rehypePlugins'
|
||||
> & {
|
||||
preset?: 'fumadocs';
|
||||
remarkPlugins?: ResolvePlugins;
|
||||
rehypePlugins?: ResolvePlugins;
|
||||
|
||||
@@ -31,6 +32,10 @@ export type MDXOptions = Omit<
|
||||
remarkImageOptions?: Plugins.RemarkImageOptions | false;
|
||||
};
|
||||
|
||||
export type CompilerOptions =
|
||||
| (CompileOptions & { preset: 'minimal' })
|
||||
| FumadocsPresetOptions;
|
||||
|
||||
export interface CompileMDXOptions {
|
||||
source: string;
|
||||
/**
|
||||
@@ -38,7 +43,6 @@ export interface CompileMDXOptions {
|
||||
*/
|
||||
filePath?: string;
|
||||
|
||||
mdxOptions?: MDXOptions;
|
||||
components?: MDXComponents;
|
||||
scope?: Record<string, unknown>;
|
||||
|
||||
@@ -58,7 +62,7 @@ export interface CompileMDXResult<TFrontmatter = Record<string, unknown>> {
|
||||
exports: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export function createCompiler(mdxOptions?: MDXOptions) {
|
||||
export function createCompiler(mdxOptions?: CompilerOptions) {
|
||||
let instance: ReturnType<typeof createProcessor> | undefined;
|
||||
|
||||
function getProcessor() {
|
||||
@@ -68,7 +72,9 @@ export function createCompiler(mdxOptions?: MDXOptions) {
|
||||
if (!format || format === 'detect') format = 'mdx';
|
||||
|
||||
return (instance = createProcessor({
|
||||
...getCompileOptions(mdxOptions),
|
||||
...(mdxOptions?.preset === 'minimal'
|
||||
? mdxOptions
|
||||
: getCompileOptions(mdxOptions)),
|
||||
format,
|
||||
}));
|
||||
}
|
||||
@@ -94,7 +100,7 @@ export function createCompiler(mdxOptions?: MDXOptions) {
|
||||
return getProcessor().process(from);
|
||||
},
|
||||
async compile<Frontmatter extends object = Record<string, unknown>>(
|
||||
options: Omit<CompileMDXOptions, 'mdxOptions'>,
|
||||
options: CompileMDXOptions,
|
||||
): Promise<CompileMDXResult<Frontmatter>> {
|
||||
const { scope = {}, skipRender } = options;
|
||||
const { frontmatter, content } = parseFrontmatter(options.source);
|
||||
@@ -129,15 +135,23 @@ export function createCompiler(mdxOptions?: MDXOptions) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `createCompiler()` API instead, this function will always create a new compiler instance.
|
||||
*/
|
||||
export async function compileMDX<
|
||||
Frontmatter extends object = Record<string, unknown>,
|
||||
>(options: CompileMDXOptions): Promise<CompileMDXResult<Frontmatter>> {
|
||||
>(
|
||||
options: CompileMDXOptions & {
|
||||
mdxOptions?: CompilerOptions;
|
||||
},
|
||||
): Promise<CompileMDXResult<Frontmatter>> {
|
||||
const compiler = createCompiler(options.mdxOptions);
|
||||
|
||||
return compiler.compile(options);
|
||||
}
|
||||
|
||||
function getCompileOptions({
|
||||
preset: _,
|
||||
rehypeCodeOptions,
|
||||
remarkImageOptions,
|
||||
rehypeTocOptions,
|
||||
@@ -146,7 +160,7 @@ function getCompileOptions({
|
||||
remarkNpmOptions,
|
||||
imageDir = './public',
|
||||
...options
|
||||
}: MDXOptions = {}): CompileOptions {
|
||||
}: FumadocsPresetOptions = {}): CompileOptions {
|
||||
function getPlugin<K extends keyof typeof Plugins>(
|
||||
name: K,
|
||||
): (typeof Plugins)[K] | null {
|
||||
@@ -203,3 +217,6 @@ function getCompileOptions({
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
// backward compatible
|
||||
export type { CompilerOptions as MDXOptions };
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
"@mdx-js/mdx": "^3.1.0",
|
||||
"@standard-schema/spec": "^1.0.0",
|
||||
"chokidar": "^4.0.3",
|
||||
"esbuild": "^0.25.6",
|
||||
"esbuild": "^0.25.8",
|
||||
"estree-util-value-to-estree": "^3.4.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lru-cache": "^11.1.0",
|
||||
@@ -72,7 +72,6 @@
|
||||
"zod": "^4.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react": "^19.1.0",
|
||||
"@fumadocs/mdx-remote": "workspace:*",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/mdast": "^4.0.3",
|
||||
@@ -81,19 +80,20 @@
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"mdast-util-mdx-jsx": "^3.2.0",
|
||||
"next": "^15.4.1",
|
||||
"next": "^15.4.2",
|
||||
"react": "^19.1.0",
|
||||
"tsconfig": "workspace:*",
|
||||
"unified": "^11.0.5",
|
||||
"vfile": "^6.0.3",
|
||||
"vite": "^7.0.4",
|
||||
"webpack": "^5.100.1"
|
||||
"vite": "^7.0.5",
|
||||
"webpack": "^5.100.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"@fumadocs/mdx-remote": "^1.2.0",
|
||||
"@fumadocs/mdx-remote": "^1.4.0",
|
||||
"fumadocs-core": "^14.0.0 || ^15.0.0",
|
||||
"next": "^15.3.0",
|
||||
"vite": "6.x.x"
|
||||
"react": "*",
|
||||
"vite": "6.x.x || 7.x.x"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react": {
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
GlobalConfig,
|
||||
MetaCollection,
|
||||
} from '@/config/define';
|
||||
import type { ProcessorOptions } from '@mdx-js/mdx';
|
||||
|
||||
export function buildConfig(
|
||||
config: Record<string, unknown>,
|
||||
@@ -40,11 +41,26 @@ export function buildConfig(
|
||||
];
|
||||
}
|
||||
|
||||
let cachedMdxOptions: Promise<ProcessorOptions> | undefined;
|
||||
return [
|
||||
null,
|
||||
{
|
||||
global: globalConfig,
|
||||
collections,
|
||||
async getDefaultMDXOptions(): Promise<ProcessorOptions> {
|
||||
if (cachedMdxOptions) return cachedMdxOptions;
|
||||
|
||||
const input = this.global?.mdxOptions;
|
||||
async function uncached(): Promise<ProcessorOptions> {
|
||||
const options = typeof input === 'function' ? await input() : input;
|
||||
const { getDefaultMDXOptions } = await import('@/utils/mdx-options');
|
||||
|
||||
if (options?.preset === 'minimal') return options;
|
||||
return getDefaultMDXOptions(options ?? {});
|
||||
}
|
||||
|
||||
return (cachedMdxOptions = uncached());
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type MDXOptions } from '@/utils/build-mdx';
|
||||
import { frontmatterSchema, metaSchema } from '@/utils/schema';
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
||||
import type { DefaultMDXOptions } from '@/utils/mdx-options';
|
||||
import type { ProcessorOptions } from '@mdx-js/mdx';
|
||||
|
||||
export type CollectionSchema<Schema extends StandardSchemaV1, Context> =
|
||||
| Schema
|
||||
@@ -35,7 +35,7 @@ export interface DocCollection<
|
||||
> extends BaseCollection {
|
||||
type: 'doc';
|
||||
|
||||
mdxOptions?: MDXOptions;
|
||||
mdxOptions?: ProcessorOptions;
|
||||
|
||||
/**
|
||||
* Load files with async
|
||||
@@ -56,13 +56,17 @@ export interface DocsCollection<
|
||||
meta: MetaCollection<MetaSchema>;
|
||||
}
|
||||
|
||||
type GlobalConfigMDXOptions =
|
||||
| ({ preset?: 'fumadocs' } & DefaultMDXOptions)
|
||||
| ({
|
||||
preset: 'minimal';
|
||||
} & ProcessorOptions);
|
||||
|
||||
export interface GlobalConfig {
|
||||
/**
|
||||
* Configure global MDX options
|
||||
*/
|
||||
mdxOptions?:
|
||||
| DefaultMDXOptions
|
||||
| (() => DefaultMDXOptions | Promise<DefaultMDXOptions>);
|
||||
mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
|
||||
|
||||
/**
|
||||
* Fetch last modified time with specified version control
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export * from './define';
|
||||
export {
|
||||
loadDefaultOptions,
|
||||
getDefaultMDXOptions,
|
||||
type DefaultMDXOptions,
|
||||
} from '../utils/mdx-options';
|
||||
export { frontmatterSchema, metaSchema } from '../utils/schema';
|
||||
|
||||
@@ -7,7 +7,6 @@ import { getGitTimestamp } from './utils/git-timestamp';
|
||||
import { validate, ValidationError } from '@/utils/schema';
|
||||
import { fumaMatter } from '@/utils/fuma-matter';
|
||||
import { countLines } from '@/utils/count-lines';
|
||||
import { loadDefaultOptions } from '@/utils/mdx-options';
|
||||
|
||||
export interface Options {
|
||||
configPath: string;
|
||||
@@ -52,7 +51,7 @@ export default async function loader(
|
||||
|
||||
let data = matter.data;
|
||||
const mdxOptions =
|
||||
collection?.mdxOptions ?? (await loadDefaultOptions(config));
|
||||
collection?.mdxOptions ?? (await config.getDefaultMDXOptions());
|
||||
|
||||
if (collection?.schema) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createCompiler, type MDXOptions } from '@fumadocs/mdx-remote';
|
||||
import { createCompiler } from '@fumadocs/mdx-remote';
|
||||
import type { LoadedConfig } from '@/utils/config';
|
||||
import { remarkInclude } from '@/mdx-plugins/remark-include';
|
||||
import {
|
||||
@@ -9,32 +9,36 @@ import { _runtime, createMDXSource } from '@/runtime/index';
|
||||
import type { RuntimeAsync } from '@/runtime/types';
|
||||
|
||||
async function initCompiler(config: LoadedConfig, collection: string) {
|
||||
let mdxOptions: MDXOptions | undefined;
|
||||
|
||||
const col = config.collections.get(collection);
|
||||
if (col?.type === 'doc') mdxOptions = col.mdxOptions as MDXOptions;
|
||||
else if (col?.type === 'docs')
|
||||
mdxOptions = col.docs?.mdxOptions as MDXOptions;
|
||||
|
||||
if (!mdxOptions) {
|
||||
config._mdx_async ??= {};
|
||||
const async = config._mdx_async;
|
||||
const globalConfig = config.global;
|
||||
|
||||
if (globalConfig && !async.cachedMdxOptions) {
|
||||
async.cachedMdxOptions =
|
||||
typeof globalConfig.mdxOptions === 'function'
|
||||
? await globalConfig.mdxOptions()
|
||||
: globalConfig.mdxOptions;
|
||||
}
|
||||
|
||||
mdxOptions = async.cachedMdxOptions;
|
||||
switch (col?.type) {
|
||||
case 'doc':
|
||||
if (col.mdxOptions)
|
||||
return createCompiler({
|
||||
preset: 'minimal',
|
||||
...col.mdxOptions,
|
||||
});
|
||||
break;
|
||||
case 'docs':
|
||||
if (col.docs.mdxOptions)
|
||||
return createCompiler({
|
||||
preset: 'minimal',
|
||||
...col.docs.mdxOptions,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
const remarkPlugins = mdxOptions?.remarkPlugins ?? [];
|
||||
let defaultMdxOptions = config.global?.mdxOptions;
|
||||
if (typeof defaultMdxOptions === 'function')
|
||||
defaultMdxOptions = await defaultMdxOptions();
|
||||
|
||||
if (defaultMdxOptions?.preset === 'minimal') {
|
||||
return createCompiler(defaultMdxOptions);
|
||||
}
|
||||
|
||||
const remarkPlugins = defaultMdxOptions?.remarkPlugins ?? [];
|
||||
return createCompiler({
|
||||
...mdxOptions,
|
||||
...defaultMdxOptions,
|
||||
remarkPlugins: (v) =>
|
||||
typeof remarkPlugins === 'function'
|
||||
? [remarkInclude, ...remarkPlugins(v), remarkStructure]
|
||||
|
||||
@@ -6,12 +6,7 @@ type Processor = ReturnType<typeof createProcessor>;
|
||||
|
||||
const cache = new Map<string, Processor>();
|
||||
|
||||
export interface MDXOptions extends ProcessorOptions {
|
||||
/**
|
||||
* Name of collection
|
||||
*/
|
||||
collection?: string;
|
||||
|
||||
interface BuildMDXOptions extends ProcessorOptions {
|
||||
/**
|
||||
* Specify a file path for source
|
||||
*/
|
||||
@@ -41,21 +36,21 @@ declare module 'vfile' {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cacheKey -- key to cache processor
|
||||
* @param cacheKey - key to cache processor
|
||||
* @param source - mdx content
|
||||
* @param options - MDX options
|
||||
*/
|
||||
export async function buildMDX(
|
||||
cacheKey: string,
|
||||
source: string,
|
||||
options: MDXOptions,
|
||||
options: BuildMDXOptions,
|
||||
): Promise<VFile> {
|
||||
const { filePath, frontmatter, data, ...rest } = options;
|
||||
|
||||
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
||||
let format = options.format;
|
||||
if (!format && filePath) {
|
||||
format = filePath.endsWith('.mdx') ? 'mdx' : 'md';
|
||||
if (filePath) {
|
||||
format ??= filePath.endsWith('.mdx') ? 'mdx' : 'md';
|
||||
}
|
||||
|
||||
format ??= 'mdx';
|
||||
const key = `${cacheKey}:${format}`;
|
||||
let cached = cache.get(key);
|
||||
@@ -77,7 +72,7 @@ export async function buildMDX(
|
||||
data: {
|
||||
...data,
|
||||
frontmatter,
|
||||
_compiler: options._compiler,
|
||||
_compiler,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import type {
|
||||
import type { ProcessorOptions } from '@mdx-js/mdx';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { buildConfig } from '@/config/build';
|
||||
import type { MDXOptions as RemoteMdxOptions } from '@fumadocs/mdx-remote';
|
||||
|
||||
export function findConfigFile(): string {
|
||||
return path.resolve('source.config.ts');
|
||||
@@ -20,13 +19,7 @@ export interface LoadedConfig {
|
||||
|
||||
global?: GlobalConfig;
|
||||
|
||||
_mdx_loader?: {
|
||||
cachedOptions?: ProcessorOptions;
|
||||
};
|
||||
|
||||
_mdx_async?: {
|
||||
cachedMdxOptions?: RemoteMdxOptions;
|
||||
};
|
||||
getDefaultMDXOptions(): Promise<ProcessorOptions>;
|
||||
}
|
||||
|
||||
let cache: {
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as plugins from 'fumadocs-core/mdx-plugins';
|
||||
import type { ProcessorOptions } from '@mdx-js/mdx';
|
||||
import type { Pluggable } from 'unified';
|
||||
import remarkMdxExport from '@/mdx-plugins/remark-exports';
|
||||
import type { LoadedConfig } from '@/utils/config';
|
||||
|
||||
type ResolvePlugins = Pluggable[] | ((v: Pluggable[]) => Pluggable[]);
|
||||
|
||||
@@ -101,20 +100,3 @@ export function getDefaultMDXOptions({
|
||||
rehypePlugins,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadDefaultOptions(
|
||||
config: LoadedConfig,
|
||||
): Promise<ProcessorOptions> {
|
||||
const input = config.global?.mdxOptions;
|
||||
config._mdx_loader ??= {};
|
||||
|
||||
const mdxLoader = config._mdx_loader;
|
||||
if (!mdxLoader.cachedOptions) {
|
||||
mdxLoader.cachedOptions =
|
||||
typeof input === 'function'
|
||||
? getDefaultMDXOptions(await input())
|
||||
: getDefaultMDXOptions(input ?? {});
|
||||
}
|
||||
|
||||
return mdxLoader.cachedOptions;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,7 @@ export default function mdx(config: Record<string, unknown>): Plugin {
|
||||
};
|
||||
}
|
||||
|
||||
const { loadDefaultOptions } = await import('@/utils/mdx-options');
|
||||
mdxOptions ??= await loadDefaultOptions(loaded);
|
||||
mdxOptions ??= await loaded.getDefaultMDXOptions();
|
||||
|
||||
// ensure the line number is correct in dev mode
|
||||
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
||||
|
||||
@@ -70,19 +70,19 @@
|
||||
"react-hook-form": "^7.60.0",
|
||||
"remark": "^15.0.1",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"xml-js": "^1.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scalar/api-client-react": "^1.3.22",
|
||||
"@scalar/api-client-react": "^1.3.23",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/openapi-sampler": "^1.0.3",
|
||||
"@types/react": "^19.1.8",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"json-schema-typed": "^8.0.1",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"openapi-types": "^12.1.3",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tsc-alias": "^1.8.16",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^24.0.13",
|
||||
"@types/node": "^24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
|
||||
@@ -42,18 +42,18 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-popover": "^1.1.14",
|
||||
"@shikijs/twoslash": "^3.8.0",
|
||||
"@shikijs/twoslash": "^3.8.1",
|
||||
"mdast-util-from-markdown": "^2.0.2",
|
||||
"mdast-util-gfm": "^3.1.0",
|
||||
"mdast-util-to-hast": "^13.2.0",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"twoslash": "^0.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "^19.1.8",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-ui": "workspace:*",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"hast-util-to-jsx-runtime": "^2.3.6",
|
||||
"remark": "^15.0.1",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"shiki": "^3.8.0",
|
||||
"shiki": "^3.8.1",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"ts-morph": "^26.0.0",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
@@ -50,7 +50,7 @@
|
||||
"@types/estree": "^1.0.8",
|
||||
"@types/hast": "^3.0.4",
|
||||
"@types/mdast": "^4.0.3",
|
||||
"@types/node": "24.0.13",
|
||||
"@types/node": "24.0.15",
|
||||
"@types/react": "19.1.8",
|
||||
"@types/react-dom": "19.1.6",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
|
||||
@@ -97,20 +97,20 @@
|
||||
"lodash.merge": "^4.6.2",
|
||||
"next-themes": "^0.4.6",
|
||||
"postcss-selector-parser": "^7.1.0",
|
||||
"react-medium-image-zoom": "^5.2.14",
|
||||
"react-medium-image-zoom": "^5.3.0",
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"tailwind-merge": "^3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fumadocs/cli": "workspace:*",
|
||||
"@next/eslint-plugin-next": "^15.4.1",
|
||||
"@next/eslint-plugin-next": "^15.4.2",
|
||||
"@tailwindcss/cli": "^4.1.11",
|
||||
"@types/lodash.merge": "^4.6.9",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"next": "15.4.1",
|
||||
"next": "15.4.2",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"tsc-alias": "^1.8.16",
|
||||
"tsconfig": "workspace:*"
|
||||
|
||||
Generated
+1164
-1089
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user