-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.mjs
More file actions
43 lines (42 loc) · 1.42 KB
/
astro.config.mjs
File metadata and controls
43 lines (42 loc) · 1.42 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
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import fs from 'fs';
import path from 'path';
import remarkDrawingBlocks from './src/plugins/remark-drawing-blocks.mjs';
export default defineConfig({
site: 'https://aiep.dev',
integrations: [sitemap()],
markdown: {
remarkPlugins: [remarkDrawingBlocks],
shikiConfig: {
theme: 'github-light',
},
},
vite: {
plugins: [
{
name: 'serve-well-known',
configureServer(server) {
server.middlewares.use((req, res, next) => {
const url = req.url?.split('?')[0];
if (!url?.startsWith('/.well-known/')) return next();
let filePath = path.join(process.cwd(), 'public', url);
// resolve directory to index.html
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
filePath = path.join(filePath, 'index.html');
}
if (!fs.existsSync(filePath)) return next();
const ext = path.extname(filePath).toLowerCase();
const types = {
'.html': 'text/html; charset=utf-8',
'.json': 'application/json; charset=utf-8',
'.txt': 'text/plain; charset=utf-8',
};
res.setHeader('Content-Type', types[ext] || 'application/octet-stream');
res.end(fs.readFileSync(filePath));
});
},
},
],
},
});