-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathastro.config.mjs
More file actions
47 lines (45 loc) · 1.65 KB
/
Copy pathastro.config.mjs
File metadata and controls
47 lines (45 loc) · 1.65 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
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://worstofbreed.net',
vite: {
ssr: {
external: ['node:fs/promises'],
},
},
integrations: [{
name: 'move-redirects',
hooks: {
'astro:build:done': async ({
dir
}) => {
const fs = await import('node:fs/promises');
const path = await import('node:path');
const {
fileURLToPath
} = await import('node:url');
const distDir = fileURLToPath(dir);
// Astro might output 'redirects' or 'redirects/index.html' depending on configuration
// In static mode for endpoint .ts, it usually outputs 'redirects' (no extension) or 'redirects.html'
// Let's check for 'redirects' first
const src = path.join(distDir, 'redirects');
const dest = path.join(distDir, '_redirects');
try {
await fs.rename(src, dest);
console.log('Successfully renamed redirects to _redirects');
} catch (e) {
// If not found, try redirects.html (less likely for GET endpoint returning plain text but possible)
try {
const srcHtml = path.join(distDir, 'redirects.html');
await fs.rename(srcHtml, dest);
console.log('Successfully renamed redirects.html to _redirects');
} catch(e2) {
console.warn('Could not find redirects file to rename. Build might be missing it.', e.message);
}
}
}
}
}, sitemap({
filter: (page) => !page.includes('/social') && !page.includes('/imprint') && !page.includes('/privacy')
})]
});