Skip to content

Commit 6e44c6f

Browse files
committed
fix: root page
1 parent 217cb84 commit 6e44c6f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

vite.config.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react";
33

4+
function getBasePath() {
5+
const repository = process.env.GITHUB_REPOSITORY;
6+
7+
if (!repository) {
8+
return "/";
9+
}
10+
11+
const [owner, repo] = repository.split("/");
12+
13+
if (!owner || !repo) {
14+
return "/";
15+
}
16+
17+
const expectedRootRepo = `${owner.toLowerCase()}.github.io`;
18+
19+
return repo.toLowerCase() === expectedRootRepo ? "/" : `/${repo}/`;
20+
}
21+
422
export default defineConfig({
5-
base: "/",
23+
base: getBasePath(),
624
plugins: [react()],
725
});

0 commit comments

Comments
 (0)