mirror of
https://github.com/SupertigerDev/waybar-online.git
synced 2026-03-24 08:06:37 +00:00
Add 404 redirect handling and GitHub Pages workflow configuration
This commit is contained in:
32
.github/workflows/main.yml
vendored
Normal file
32
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: gh-pages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
gh-pages:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 21.x
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
run: npm install --global pnpm
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Build Vite
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Deploy GitHub Pages
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: dist
|
||||||
10
index.html
10
index.html
@@ -12,5 +12,15 @@
|
|||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
<script>
|
||||||
|
// Redirects user from 404
|
||||||
|
(function () {
|
||||||
|
var redirect = sessionStorage.redirect;
|
||||||
|
delete sessionStorage.redirect;
|
||||||
|
if (redirect && redirect != location.href) {
|
||||||
|
history.replaceState(null, null, redirect);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
14
public/404.html
Normal file
14
public/404.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script>
|
||||||
|
sessionStorage.redirect = location.href;
|
||||||
|
const projectPages = true; // If you're using the base .github.io domain without a path (i.e. <name>.github.io is your home page), set this to false
|
||||||
|
const l = window.location;
|
||||||
|
const repo = projectPages ? "/" + l.pathname.split("/")[1] : "";
|
||||||
|
l.replace(
|
||||||
|
l.protocol + "//" + l.hostname + (l.port ? ":" + l.port : "") + repo
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user