-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.mjs
More file actions
63 lines (60 loc) · 1.63 KB
/
astro.config.mjs
File metadata and controls
63 lines (60 loc) · 1.63 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
59
60
61
62
import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import tailwind from "@astrojs/tailwind";
import remarkWikiLink from 'remark-wiki-link';
import vercel from "@astrojs/vercel";
import sitemap from '@astrojs/sitemap';
import fs from 'fs';
import path from 'path';
// Build a map of permalinks to their actual category paths
const getPermalinksMap = () => {
const notesDir = path.resolve('./src/content/notes');
const map = {};
if (fs.existsSync(notesDir)) {
const categories = fs.readdirSync(notesDir);
categories.forEach(category => {
const categoryPath = path.join(notesDir, category);
if (fs.statSync(categoryPath).isDirectory()) {
fs.readdirSync(categoryPath).forEach(file => {
if (file.endsWith('.md')) {
const slug = file.replace('.md', '');
map[slug] = `${category}/${slug}`;
}
});
}
});
}
return map;
};
const permalinksMap = getPermalinksMap();
export default defineConfig({
site: 'https://my-aws-docs.vercel.app',
integrations: [
react(),
tailwind({
applyBaseStyles: false,
}),
sitemap({
filter: (page) => !page.includes('/404'),
}),
],
markdown: {
remarkPlugins: [
[
remarkWikiLink,
{
pageResolver: (name) => [name.toLowerCase().replace(/ /g, '-')],
hrefTemplate: (permalink) => {
const mapped = permalinksMap[permalink] || `aws/${permalink}`;
return `/docs/${mapped}`;
},
},
],
],
shikiConfig: {
theme: 'github-light',
},
},
output: "static",
adapter: vercel(),
});