-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathastro.config.ts
84 lines (78 loc) · 1.99 KB
/
astro.config.ts
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
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import react from '@astrojs/react';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import rehypePrettyCode from 'rehype-pretty-code';
import fs from 'fs/promises';
import graymatter from 'gray-matter';
import path from 'path';
import { rehypePluginLinkHeading } from './plugins/rehypePluginLinkHeading';
import { rehypePluginTableWrapper } from './plugins/rehypePluginTableWrapper';
import { remarkPluginReadingTime } from './plugins/remarkPluginReadingTime';
const BLOG_DIR = './src/content/blog';
const getBlogRoutesRedirect = async () => {
const blogRoutesOldSlug = await fs.readdir(BLOG_DIR);
const blogRoutes = blogRoutesOldSlug
.map(post => {
const frontmatter = graymatter.read(path.join(BLOG_DIR, post));
return {
...frontmatter,
slug: frontmatter.data.slug,
}
})
.map(({ slug }) => [
`/${slug}`,
`/blog/${slug}`,
]);
return Object.fromEntries(blogRoutes);
}
const disableSitemap = [
'/blog/drafts',
];
// https://astro.build/config
export default defineConfig({
site: 'https://noghartt.dev',
integrations: [
sitemap({
filter: (page) => {
try {
const url = new URL(page);
const shouldAdd = disableSitemap.every(path => !url.pathname.startsWith(path));
return shouldAdd;
} catch (err) {
return false;
}
}
}),
react(),
],
output: "static",
markdown: {
syntaxHighlight: false,
remarkPlugins: [
remarkMath,
remarkPluginReadingTime,
],
rehypePlugins: [
rehypeKatex,
[
rehypePrettyCode,
{
theme: 'github-light',
keepBackground: false,
},
],
rehypePluginLinkHeading,
rehypePluginTableWrapper,
],
},
vite: {
optimizeDeps: {
exclude: ["@resvg/resvg-js"],
},
},
redirects: {
...await getBlogRoutesRedirect(),
}
});