Repository navigation
Expand file tree
/
Copy pathastro.config.mjs
More file actions
58 lines (56 loc) · 1.83 KB
/
Copy pathastro.config.mjs
File metadata and controls
58 lines (56 loc) · 1.83 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
// @ts-check
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import { unified } from '@astrojs/markdown-remark';
import tailwindcss from '@tailwindcss/vite';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import path from 'path';
/**
* Inject a default `layout:` into MDX frontmatter when the file lives under
* a content-page directory and the author didn't set one. Lets posts skip
* the boilerplate header line in 99% of cases.
*/
function injectDefaultLayout(layoutPath, includeDirs) {
return () => (_tree, file) => {
const fm = file?.data?.astro?.frontmatter;
if (!fm || fm.layout) return;
const sourcePath = file.history?.[0] ?? file.path ?? '';
if (!includeDirs.some((dir) => sourcePath.includes(dir))) return;
fm.layout = layoutPath;
};
}
export default defineConfig({
site: 'https://viniciusdc.github.io',
// Stable redirects for old URLs that link in from external archives.
redirects: {
// GSoC 2020 work-product submission — was hosted at this path on the
// previous Jekyll site; still linked from the GSoC archive.
'/Work product/': '/projects/conda-forge-autotick-bot/',
'/Work%20product/': '/projects/conda-forge-autotick-bot/',
},
// Astro 7's default `satteri` processor skips remark/rehype plugins, so
// opt back into the unified pipeline; MDX inherits these plugins.
markdown: {
processor: unified({
remarkPlugins: [
remarkMath,
injectDefaultLayout('@/layouts/ArticleLayout.astro', [
'/pages/writing/',
'/pages/projects/',
]),
],
rehypePlugins: [rehypeKatex],
}),
},
integrations: [mdx()],
devToolbar: { enabled: false },
vite: {
plugins: [tailwindcss()],
resolve: {
alias: {
'@': path.resolve('./src'),
},
},
},
});