Skip to content

Commit de8ff70

Browse files
github workflow added
1 parent 507aa01 commit de8ff70

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,18 @@
99
<body class="dark:bg-gray-900">
1010
<div id="app"></div>
1111
<script type="module" src="/src/main.ts"></script>
12+
<script>
13+
// GitHub Pages SPA redirect
14+
(function(l) {
15+
if (l.search[1] === '/' ) {
16+
var decoded = l.search.slice(1).split('&').map(function(s) {
17+
return s.replace(/~and~/g, '&')
18+
}).join('?');
19+
window.history.replaceState(null, null,
20+
l.pathname.slice(0, -1) + decoded + l.hash
21+
);
22+
}
23+
}(window.location))
24+
</script>
1225
</body>
1326
</html>

public/404.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Redirecting...</title>
7+
<script>
8+
// GitHub Pages SPA redirect
9+
// This script takes the current URL and converts the path and query
10+
// string into just a query string, and then redirects the browser
11+
// to that URL with new query string + hash, and no path.
12+
//
13+
// For example:
14+
// /foo/bar/baz?abc=123#def
15+
// becomes:
16+
// /?p=/foo/bar/baz&q=abc%3D123#def
17+
//
18+
// Note: any hash in the original URL is preserved in the hash.
19+
var pathSegmentsToKeep = 1;
20+
21+
var l = window.location;
22+
l.replace(
23+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
24+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
25+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
26+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
27+
l.hash
28+
);
29+
</script>
30+
</head>
31+
<body>
32+
<p>Redirecting...</p>
33+
</body>
34+
</html>

src/router/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
1+
import { createRouter, createWebHistory } from 'vue-router'
22

33
const router = createRouter({
4-
history: import.meta.env.PROD
5-
? createWebHashHistory()
6-
: createWebHistory(import.meta.env.BASE_URL),
4+
history: createWebHistory(import.meta.env.BASE_URL),
75
scrollBehavior(to, from, savedPosition) {
86
return savedPosition || { left: 0, top: 0 }
97
},

vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ export default defineConfig({
1414
'@': fileURLToPath(new URL('./src', import.meta.url)),
1515
},
1616
},
17+
build: {
18+
rollupOptions: {
19+
output: {
20+
manualChunks: undefined,
21+
},
22+
},
23+
},
1724
})

0 commit comments

Comments
 (0)