Skip to content

Commit e8be8b9

Browse files
committed
fix tuirbo.json
1 parent 09f01a0 commit e8be8b9

File tree

6 files changed

+75
-82
lines changed

6 files changed

+75
-82
lines changed

apps/docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
"tinyglobby": "^0.2.15",
9595
"ts-morph": "^27.0.2",
9696
"tsconfig": "workspace:*",
97-
"typescript": "^5.9.3"
97+
"typescript": "^5.9.3",
98+
"unified": "^11.0.5"
9899
},
99100
"browserslist": [
100101
"extends browserslist-config-baseline/2024"

apps/docs/scripts/preload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createMdxPlugin } from 'fumadocs-mdx/bun';
22
import { postInstall } from 'fumadocs-mdx/next';
33

4-
const configPath = 'source.script.ts';
4+
process.env.LINT = '1';
5+
const configPath = 'source.config.ts';
56
await postInstall({ configPath });
67
Bun.plugin(createMdxPlugin({ configPath }));

apps/docs/source.config.ts

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import type { RemarkFeedbackBlockOptions } from 'fumadocs-core/mdx-plugins';
88
import type { RemarkAutoTypeTableOptions } from 'fumadocs-typescript';
99
import { shikiConfig } from './lib/shiki';
1010
import { metaSchema, pageSchema } from 'fumadocs-core/source/schema';
11+
import { visit } from 'unist-util-visit';
12+
import type { Transformer } from 'unified';
13+
import type { Root } from 'mdast';
14+
15+
const isLint = process.env.LINT === '1';
1116

1217
export const docs = defineDocs({
1318
docs: {
@@ -22,6 +27,7 @@ export const docs = defineDocs({
2227
postprocess: {
2328
includeProcessedMarkdown: true,
2429
extractLinkReferences: true,
30+
valueToExport: ['elementIds'],
2531
},
2632
async: true,
2733
async mdxOptions(environment) {
@@ -56,21 +62,23 @@ export const docs = defineDocs({
5662
remarkStructureOptions: {
5763
types: [...remarkStructureDefaultOptions.types, 'code'],
5864
},
59-
rehypeCodeOptions: {
60-
langs: ['ts', 'js', 'html', 'tsx', 'mdx'],
61-
inline: 'tailing-curly-colon',
62-
themes: {
63-
light: 'catppuccin-latte',
64-
dark: 'catppuccin-mocha',
65-
},
66-
transformers: [
67-
...(rehypeCodeDefaultOptions.transformers ?? []),
68-
transformerTwoslash({
69-
typesCache: createFileSystemTypesCache(),
70-
}),
71-
transformerEscape(),
72-
],
73-
},
65+
rehypeCodeOptions: isLint
66+
? false
67+
: {
68+
langs: ['ts', 'js', 'html', 'tsx', 'mdx'],
69+
inline: 'tailing-curly-colon',
70+
themes: {
71+
light: 'catppuccin-latte',
72+
dark: 'catppuccin-mocha',
73+
},
74+
transformers: [
75+
...(rehypeCodeDefaultOptions.transformers ?? []),
76+
transformerTwoslash({
77+
typesCache: createFileSystemTypesCache(),
78+
}),
79+
transformerEscape(),
80+
],
81+
},
7482
remarkCodeTabOptions: {
7583
parseMdx: true,
7684
},
@@ -79,13 +87,15 @@ export const docs = defineDocs({
7987
id: 'package-manager',
8088
},
8189
},
82-
remarkPlugins: [
83-
remarkSteps,
84-
remarkMath,
85-
[remarkFeedbackBlock, feedbackOptions],
86-
[remarkAutoTypeTable, typeTableOptions],
87-
remarkTypeScriptToJavaScript,
88-
],
90+
remarkPlugins: isLint
91+
? [remarkElementIds]
92+
: [
93+
remarkSteps,
94+
remarkMath,
95+
[remarkFeedbackBlock, feedbackOptions],
96+
[remarkAutoTypeTable, typeTableOptions],
97+
remarkTypeScriptToJavaScript,
98+
],
8999
rehypePlugins: (v) => [rehypeKatex, ...v],
90100
})(environment);
91101
},
@@ -110,14 +120,16 @@ export const blog = defineCollections({
110120
const { remarkSteps } = await import('fumadocs-core/mdx-plugins/remark-steps');
111121

112122
return applyMdxPreset({
113-
rehypeCodeOptions: {
114-
inline: 'tailing-curly-colon',
115-
themes: {
116-
light: 'catppuccin-latte',
117-
dark: 'catppuccin-mocha',
118-
},
119-
transformers: [...(rehypeCodeDefaultOptions.transformers ?? []), transformerEscape()],
120-
},
123+
rehypeCodeOptions: isLint
124+
? false
125+
: {
126+
inline: 'tailing-curly-colon',
127+
themes: {
128+
light: 'catppuccin-latte',
129+
dark: 'catppuccin-mocha',
130+
},
131+
transformers: [...(rehypeCodeDefaultOptions.transformers ?? []), transformerEscape()],
132+
},
121133
remarkCodeTabOptions: {
122134
parseMdx: true,
123135
},
@@ -126,7 +138,7 @@ export const blog = defineCollections({
126138
id: 'package-manager',
127139
},
128140
},
129-
remarkPlugins: [remarkSteps],
141+
remarkPlugins: isLint ? [remarkElementIds] : [remarkSteps],
130142
})(environment);
131143
},
132144
});
@@ -151,6 +163,25 @@ function transformerEscape(): ShikiTransformer {
151163
};
152164
}
153165

166+
function remarkElementIds(): Transformer<Root, Root> {
167+
return (tree, file) => {
168+
file.data ??= {};
169+
file.data.elementIds ??= [];
170+
171+
visit(tree, 'mdxJsxFlowElement', (element) => {
172+
if (!element.name || !element.attributes) return;
173+
174+
const idAttr = element.attributes.find(
175+
(attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'id',
176+
);
177+
178+
if (idAttr && typeof idAttr.value === 'string') {
179+
(file.data.elementIds as string[]).push(idAttr.value);
180+
}
181+
});
182+
};
183+
}
184+
154185
export default defineConfig({
155186
plugins: [
156187
jsonSchema({

apps/docs/source.script.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbo.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
"outputs": [
1818
".output",
1919
"public/registry",
20-
"public/r",
21-
".contentlayer/**",
2220
".source/**",
23-
"!.contentlayer/.cache/**",
2421
".next/**",
2522
"!.next/cache/**",
2623
"dist/**",
24+
"css/generated/**",
2725
"out",
2826
"build",
2927
".vercel"

0 commit comments

Comments
 (0)