-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.remarkrc.js
38 lines (35 loc) · 895 Bytes
/
.remarkrc.js
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
import { fileURLToPath } from 'url';
import path from 'path';
import fs from 'fs';
import { visit } from 'unist-util-visit';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const checkLocalLinks = () => (tree, file) => {
visit(tree, 'link', (node) => {
const url = node.url;
if (url.startsWith('/docs/')) {
// Split URL into file path and hash
const [filePath] = url.split('#');
const localPath = path.join(__dirname, filePath);
if (!fs.existsSync(localPath)) {
file.message(`Local file does not exist: ${filePath}`, node);
}
}
});
};
export default {
plugins: [
[
'remark-lint-no-dead-urls',
{
skipLocalLinks: false,
skipOffline: false,
timeout: 5000,
skipUrlPatterns: [
'discord.gg',
/^\/docs\/.*/
]
}
],
checkLocalLinks
]
};