generated from mintlify/starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.config.ts
More file actions
106 lines (95 loc) · 2.92 KB
/
source.config.ts
File metadata and controls
106 lines (95 loc) · 2.92 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
defineConfig,
defineDocs,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';
import { remarkNpm } from 'fumadocs-core/mdx-plugins';
import { visit } from 'unist-util-visit';
import type { Root } from 'mdast';
// Plugin to remove auto-linked emails and URLs, keeping only explicit markdown links
function remarkNoAutoLinks() {
return (tree: Root) => {
visit(tree, 'link', (node, index, parent) => {
if (!node.url || !parent || typeof index !== 'number') return;
// Extract text content from link children
const getLinkText = (node: any): string => {
if (!node.children || node.children.length === 0) return '';
return node.children
.map((child: any) => {
if (child.type === 'text') return child.value;
if (child.type === 'code') return child.value;
return '';
})
.join('');
};
const linkText = getLinkText(node);
const url = node.url;
// Check if it's a mailto link
const isMailto = url.startsWith('mailto:');
// Check if the URL itself is an email address
const isEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(url);
// Check if it's an auto-linked URL (text content matches the URL)
// Normalize both for comparison (remove trailing slashes, etc.)
const normalizeUrl = (u: string) => u.replace(/\/$/, '').toLowerCase();
const textMatchesUrl = normalizeUrl(linkText) === normalizeUrl(url) ||
normalizeUrl(linkText) === normalizeUrl(url.replace(/^https?:\/\//, ''));
// Remove auto-links: emails, mailto links, or URLs where text matches URL
if (isMailto || isEmail || textMatchesUrl) {
// Use the link text if available, otherwise use the URL
const text = linkText || (isMailto ? url.replace('mailto:', '') : url);
// Replace the link node with a text node
parent.children[index] = {
type: 'text',
value: text,
} as any;
}
});
};
}
// You can customise Zod schemas for frontmatter and `meta.json` here
// see https://fumadocs.dev/docs/mdx/collections
export const guide = defineDocs({
dir: "content/guide",
docs: {
schema: frontmatterSchema,
postprocess: {
includeProcessedMarkdown: true
}
},
meta: {
schema: metaSchema
}
});
export const api = defineDocs({
dir: "content/api",
docs: {
schema: frontmatterSchema,
postprocess: {
includeProcessedMarkdown: true
}
},
meta: {
schema: metaSchema
}
});
export const integrations = defineDocs({
dir: "content/integrations",
docs: {
schema: frontmatterSchema,
postprocess: {
includeProcessedMarkdown: true
}
},
meta: {
schema: metaSchema
}
});
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkNpm, remarkNoAutoLinks],
remarkCodeTabOptions: {
parseMdx: true,
},
},
});