mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-24 20:09:02 +00:00
fix tuirbo.json
This commit is contained in:
@@ -94,7 +94,8 @@
|
||||
"tinyglobby": "^0.2.15",
|
||||
"ts-morph": "^27.0.2",
|
||||
"tsconfig": "workspace:*",
|
||||
"typescript": "^5.9.3"
|
||||
"typescript": "^5.9.3",
|
||||
"unified": "^11.0.5"
|
||||
},
|
||||
"browserslist": [
|
||||
"extends browserslist-config-baseline/2024"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createMdxPlugin } from 'fumadocs-mdx/bun';
|
||||
import { postInstall } from 'fumadocs-mdx/next';
|
||||
|
||||
const configPath = 'source.script.ts';
|
||||
process.env.LINT = '1';
|
||||
const configPath = 'source.config.ts';
|
||||
await postInstall({ configPath });
|
||||
Bun.plugin(createMdxPlugin({ configPath }));
|
||||
|
||||
+62
-31
@@ -8,6 +8,11 @@ import type { RemarkFeedbackBlockOptions } from 'fumadocs-core/mdx-plugins';
|
||||
import type { RemarkAutoTypeTableOptions } from 'fumadocs-typescript';
|
||||
import { shikiConfig } from './lib/shiki';
|
||||
import { metaSchema, pageSchema } from 'fumadocs-core/source/schema';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { Transformer } from 'unified';
|
||||
import type { Root } from 'mdast';
|
||||
|
||||
const isLint = process.env.LINT === '1';
|
||||
|
||||
export const docs = defineDocs({
|
||||
docs: {
|
||||
@@ -22,6 +27,7 @@ export const docs = defineDocs({
|
||||
postprocess: {
|
||||
includeProcessedMarkdown: true,
|
||||
extractLinkReferences: true,
|
||||
valueToExport: ['elementIds'],
|
||||
},
|
||||
async: true,
|
||||
async mdxOptions(environment) {
|
||||
@@ -56,21 +62,23 @@ export const docs = defineDocs({
|
||||
remarkStructureOptions: {
|
||||
types: [...remarkStructureDefaultOptions.types, 'code'],
|
||||
},
|
||||
rehypeCodeOptions: {
|
||||
langs: ['ts', 'js', 'html', 'tsx', 'mdx'],
|
||||
inline: 'tailing-curly-colon',
|
||||
themes: {
|
||||
light: 'catppuccin-latte',
|
||||
dark: 'catppuccin-mocha',
|
||||
},
|
||||
transformers: [
|
||||
...(rehypeCodeDefaultOptions.transformers ?? []),
|
||||
transformerTwoslash({
|
||||
typesCache: createFileSystemTypesCache(),
|
||||
}),
|
||||
transformerEscape(),
|
||||
],
|
||||
},
|
||||
rehypeCodeOptions: isLint
|
||||
? false
|
||||
: {
|
||||
langs: ['ts', 'js', 'html', 'tsx', 'mdx'],
|
||||
inline: 'tailing-curly-colon',
|
||||
themes: {
|
||||
light: 'catppuccin-latte',
|
||||
dark: 'catppuccin-mocha',
|
||||
},
|
||||
transformers: [
|
||||
...(rehypeCodeDefaultOptions.transformers ?? []),
|
||||
transformerTwoslash({
|
||||
typesCache: createFileSystemTypesCache(),
|
||||
}),
|
||||
transformerEscape(),
|
||||
],
|
||||
},
|
||||
remarkCodeTabOptions: {
|
||||
parseMdx: true,
|
||||
},
|
||||
@@ -79,13 +87,15 @@ export const docs = defineDocs({
|
||||
id: 'package-manager',
|
||||
},
|
||||
},
|
||||
remarkPlugins: [
|
||||
remarkSteps,
|
||||
remarkMath,
|
||||
[remarkFeedbackBlock, feedbackOptions],
|
||||
[remarkAutoTypeTable, typeTableOptions],
|
||||
remarkTypeScriptToJavaScript,
|
||||
],
|
||||
remarkPlugins: isLint
|
||||
? [remarkElementIds]
|
||||
: [
|
||||
remarkSteps,
|
||||
remarkMath,
|
||||
[remarkFeedbackBlock, feedbackOptions],
|
||||
[remarkAutoTypeTable, typeTableOptions],
|
||||
remarkTypeScriptToJavaScript,
|
||||
],
|
||||
rehypePlugins: (v) => [rehypeKatex, ...v],
|
||||
})(environment);
|
||||
},
|
||||
@@ -110,14 +120,16 @@ export const blog = defineCollections({
|
||||
const { remarkSteps } = await import('fumadocs-core/mdx-plugins/remark-steps');
|
||||
|
||||
return applyMdxPreset({
|
||||
rehypeCodeOptions: {
|
||||
inline: 'tailing-curly-colon',
|
||||
themes: {
|
||||
light: 'catppuccin-latte',
|
||||
dark: 'catppuccin-mocha',
|
||||
},
|
||||
transformers: [...(rehypeCodeDefaultOptions.transformers ?? []), transformerEscape()],
|
||||
},
|
||||
rehypeCodeOptions: isLint
|
||||
? false
|
||||
: {
|
||||
inline: 'tailing-curly-colon',
|
||||
themes: {
|
||||
light: 'catppuccin-latte',
|
||||
dark: 'catppuccin-mocha',
|
||||
},
|
||||
transformers: [...(rehypeCodeDefaultOptions.transformers ?? []), transformerEscape()],
|
||||
},
|
||||
remarkCodeTabOptions: {
|
||||
parseMdx: true,
|
||||
},
|
||||
@@ -126,7 +138,7 @@ export const blog = defineCollections({
|
||||
id: 'package-manager',
|
||||
},
|
||||
},
|
||||
remarkPlugins: [remarkSteps],
|
||||
remarkPlugins: isLint ? [remarkElementIds] : [remarkSteps],
|
||||
})(environment);
|
||||
},
|
||||
});
|
||||
@@ -151,6 +163,25 @@ function transformerEscape(): ShikiTransformer {
|
||||
};
|
||||
}
|
||||
|
||||
function remarkElementIds(): Transformer<Root, Root> {
|
||||
return (tree, file) => {
|
||||
file.data ??= {};
|
||||
file.data.elementIds ??= [];
|
||||
|
||||
visit(tree, 'mdxJsxFlowElement', (element) => {
|
||||
if (!element.name || !element.attributes) return;
|
||||
|
||||
const idAttr = element.attributes.find(
|
||||
(attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'id',
|
||||
);
|
||||
|
||||
if (idAttr && typeof idAttr.value === 'string') {
|
||||
(file.data.elementIds as string[]).push(idAttr.value);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
jsonSchema({
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import { defineConfig } from 'fumadocs-mdx/config';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { Root } from 'mdast';
|
||||
|
||||
export { blog, docs } from './source.config';
|
||||
|
||||
function remarkElementIds() {
|
||||
return (tree: Root, vfile: unknown) => {
|
||||
const file = vfile as { data?: { elementIds?: string[] } };
|
||||
file.data ??= {};
|
||||
file.data.elementIds ??= [];
|
||||
|
||||
visit(tree, 'mdxJsxFlowElement', (element) => {
|
||||
if (!element.name || !element.attributes) return;
|
||||
|
||||
const idAttr = element.attributes.find(
|
||||
(attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'id',
|
||||
);
|
||||
|
||||
if (idAttr && typeof idAttr.value === 'string') {
|
||||
file.data!.elementIds!.push(idAttr.value);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
mdxOptions: {
|
||||
valueToExport: ['elementIds', 'toc'],
|
||||
remarkNpmOptions: {
|
||||
persist: {
|
||||
id: 'package-manager',
|
||||
},
|
||||
},
|
||||
remarkHeadingOptions: {
|
||||
generateToc: true,
|
||||
},
|
||||
remarkPlugins: [remarkElementIds],
|
||||
rehypePlugins: () => [],
|
||||
},
|
||||
});
|
||||
Generated
+8
-5
+1
-3
@@ -17,13 +17,11 @@
|
||||
"outputs": [
|
||||
".output",
|
||||
"public/registry",
|
||||
"public/r",
|
||||
".contentlayer/**",
|
||||
".source/**",
|
||||
"!.contentlayer/.cache/**",
|
||||
".next/**",
|
||||
"!.next/cache/**",
|
||||
"dist/**",
|
||||
"css/generated/**",
|
||||
"out",
|
||||
"build",
|
||||
".vercel"
|
||||
|
||||
Reference in New Issue
Block a user