Skip to content

Commit 32da174

Browse files
committed
🔧 Test GitHub Pages path with /webring/index.html
1 parent 498d519 commit 32da174

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

webring.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,25 @@ fetch('./members.json')
3030
// only run redirect logic if on next.html, prev.html, or rand.html
3131
if (['next.html','prev.html','rand.html'].includes(path)) {
3232

33+
// NOTE: If you are hosting this on GitHub Pages, make sure to include your repo name in paths.
34+
// Example: instead of "/" use "/webring/index.html" (Replace "webring" with your repo name if different)
35+
// This is because GitHub Pages serves your site under https://username.github.io/<repo>/
36+
// Without the repo name, it will try to load https://username.github.io/index.html (which doesn't exist).
37+
3338
// if a name is provided but does not exist, redirect to hub
3439
if (name && !members.some(m => m.name === name)) {
35-
window.location.href = '/';
40+
window.location.href = '/webring/index.html';
3641
} else if (path === 'next.html' && name) {
3742
const idx = members.findIndex(m => m.name === name);
3843
const next = members[(idx + 1) % members.length];
39-
window.location.href = next ? next.site : '/';
44+
window.location.href = next ? next.site : '/webring/index.html';
4045
} else if (path === 'prev.html' && name) {
4146
const idx = members.findIndex(m => m.name === name);
4247
const prev = members[(idx - 1 + members.length) % members.length];
43-
window.location.href = prev ? prev.site : '/';
48+
window.location.href = prev ? prev.site : '/webring/index.html';
4449
} else if (path === 'rand.html') {
4550
if (members.length === 0) {
46-
window.location.href = '/';
51+
window.location.href = '/webring/index.html';
4752
return;
4853
}
4954

0 commit comments

Comments
 (0)