-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdsvex.config.js
53 lines (50 loc) · 1.23 KB
/
mdsvex.config.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { defineMDSveXConfig as defineConfig } from 'mdsvex';
import wikilink from 'remark-wiki-link';
import preview, { htmlFormatter, textFormatter } from 'remark-preview';
import path from 'path';
import {
getMarkdownFiles,
parseFileNameFromPath,
normalizeFileName,
toSlug
} from './src/lib/util/wiki-link.js';
const config = defineConfig({
extensions: ['.svelte.md', '.md', '.svx'],
smartypants: {
dashes: 'oldschool'
},
remarkPlugins: [
preview(textFormatter({ length: 150, maxBlocks: 2 })),
preview(
htmlFormatter({
length: 250,
maxBlocks: 2
}),
{
attribute: 'previewHtml'
}
),
[
wikilink,
{
pageResolver: (permalink) => {
const dir = path.join(process.cwd(), 'obsidian');
const allFiles = getMarkdownFiles(dir);
const result = allFiles.find((file) => {
const parsedFileName = parseFileNameFromPath(file);
const match = normalizeFileName(permalink) === normalizeFileName(parsedFileName);
return match;
});
return result !== undefined && result.length > 0
? [`/notes${toSlug(result, dir)}`]
: ['/notes/index'];
},
hrefTemplate: (permalink) => {
return `${permalink}`;
},
aliasDivider: '|'
}
]
]
});
export default config;