-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathastro.config.mjs
More file actions
30 lines (26 loc) · 945 Bytes
/
astro.config.mjs
File metadata and controls
30 lines (26 loc) · 945 Bytes
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
import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import tailwind from "@astrojs/tailwind";
// Get base path from environment variable
// For GitHub Pages: if repo is username.github.io, use "" (root)
// Otherwise use /repo-name (must start with / and not end with /)
// Can be set via BASE_PATH env var or defaults to empty (root)
let base = process.env.BASE_PATH || "";
// Normalize base path: ensure it starts with / if not empty, and remove trailing /
if (base && !base.startsWith('/')) {
base = '/' + base;
}
if (base.endsWith('/') && base !== '/') {
base = base.slice(0, -1);
}
// Construct site URL - GitHub Pages format
const owner = process.env.GITHUB_REPOSITORY_OWNER || 'carreau';
const site = base
? `https://${owner}.github.io${base}`
: `https://${owner}.github.io`;
export default defineConfig({
integrations: [react(), tailwind()],
base: base,
site: site,
output: "static",
});