-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathastro.config.mjs
43 lines (41 loc) · 1.14 KB
/
astro.config.mjs
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
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import markdownIntegration from '@astropub/md';
import { visit } from 'unist-util-visit';
import netlify from '@astrojs/netlify';
// https://astro.build/config
export default defineConfig({
markdown: {
remarkPlugins: [rewriteLinks],
shikiConfig: {
themes: {
light: 'github-light',
dark: 'github-dark',
},
},
},
integrations: [mdx(), markdownIntegration()],
scopedStyleStrategy: 'class',
prefetch: {
defaultStrategy: 'viewport',
prefetchAll: true,
},
image: {
domains: ['pub-4c968c1e5299430eafe672b417232afa.r2.dev'],
},
});
function rewriteLinks() {
return function (tree) {
visit(tree, 'link', (node) => {
const url = node.url;
if (url.startsWith('http') && !url.includes('aria.ai')) {
node.data = node.data || {};
node.data.hProperties = node.data.hProperties || {};
node.data.hProperties.target = '_blank';
node.data.hProperties.rel = 'noopener noreferrer';
} else if (!url.startsWith('#') && !url.endsWith('/')) {
node.url += '/';
}
});
};
}