-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.mjs
More file actions
49 lines (44 loc) · 1.22 KB
/
Copy pathastro.config.mjs
File metadata and controls
49 lines (44 loc) · 1.22 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
// @ts-check
import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import icon from "astro-icon";
import mdx from "@astrojs/mdx";
// TODO: add relative imports for components, layouts, pages, etc.
const mdxLayoutSetter = () => {
// @ts-ignore
return function (_, file) {
// find relative path to layout based on file path
const relativePath = file.history[0];
const frontmatter = file.data.astro.frontmatter;
// find if layout is already set
if (frontmatter.layout) return;
// set layout based on file path
switch (true) {
case relativePath.includes("/services/"):
frontmatter.layout = "@/layouts/ServiceLayout.astro";
break;
case relativePath.includes("/works/"):
frontmatter.layout = "@/layouts/WorksLayout.astro";
break;
default:
frontmatter.layout = "@/layouts/MainLayout.astro";
}
};
};
// https://astro.build/config
export default defineConfig({
vite: { plugins: [tailwindcss()] },
markdown: {
remarkPlugins: [mdxLayoutSetter],
},
integrations: [
mdx(),
icon({
include: {
lucide: ["*"],
"vscode-icons": ["*"],
guidance: ["up-arrow"],
},
}),
],
});