Repository navigation
Expand file tree
/
Copy pathsource.config.ts
More file actions
76 lines (73 loc) · 3.16 KB
/
Copy pathsource.config.ts
File metadata and controls
76 lines (73 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig, defineDocs } from 'fumadocs-mdx/config';
import { z } from 'zod';
import { pageSchema } from 'fumadocs-core/source/schema';
import remarkGfm from 'remark-gfm';
import path from 'node:path';
import { remarkGitChangelog } from 'fumadocs-page-history/remark';
import { gitChangelogSchema } from 'fumadocs-page-history/schema';
import type { HistoryOptions } from 'fumadocs-page-history/git';
import { buildAuthorMappings } from './lib/people.js';
import { remarkSearchAnchors } from './lib/remark-search-anchors.mjs';
import { remarkImageZoom } from './lib/remark-image-zoom.mjs';
import { remarkLLMMedia } from './lib/remark-llm-media.mjs';
const historyOptions = {
repository: { url: 'https://github.com/WHUDAYS/WHUDAYS.github.io' },
authorMappings: buildAuthorMappings(),
// Vue → React rewrites can fall below Git's default rename threshold.
getHistoryPaths: (sourcePath) => sourcePath.startsWith('docs/') && sourcePath.endsWith('.mdx')
? [sourcePath.replace(/\.mdx$/, '.md')]
: [],
} satisfies HistoryOptions;
export const docs = defineDocs({
dir: 'docs',
meta: { files: ['**/meta.json'] },
docs: {
files: ['**/*.mdx'],
lastModified: true,
postprocess: {
includeProcessedMarkdown: {
output: 'function',
filterElement(node) {
if (node.data && 'searchExcluded' in node.data && node.data.searchExcluded) return false;
if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') return false;
if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') {
if (['History', 'GitContributors', 'link', 'style', 'script'].includes(node.name ?? '')) return false;
if (['div', 'span', 'center', 'p'].includes(node.name ?? '')) return 'children-only';
}
return true;
},
},
},
schema: pageSchema.extend({
description: z.string().min(10),
layout: z.string().optional(),
sidebar: z.boolean().optional(),
outline: z.union([z.boolean(), z.number(), z.array(z.number()), z.string()]).optional(),
hero: z.any().optional(),
features: z.array(z.any()).optional(),
}).extend(gitChangelogSchema.shape).passthrough(),
},
});
export default defineConfig({
mdxOptions: {
remarkPlugins: (plugins) => {
const configured = [...plugins];
const index = configured.findIndex((plugin) => plugin === remarkGfm);
if (index >= 0) configured[index] = [remarkGfm, { singleTilde: false }];
// Assign card/content targets and exclude hidden lists before indexing.
return [remarkSearchAnchors, remarkImageZoom, remarkLLMMedia, ...configured, [remarkGitChangelog, {
...historyOptions,
filter: (filePath: string) => filePath !== path.resolve('docs/index.mdx'),
display: {
locale: 'zh-CN',
hideChangelogHeader: true,
hideContributorsHeader: true,
displayAuthorsInsideCommitLine: true,
},
}]];
},
// Keep archive URLs stable; no runtime image service or remote build fetches.
remarkImageOptions: false,
rehypeCodeOptions: { themes: { light: 'github-light', dark: 'github-dark' } },
},
});