11---
22import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
33import { OLD_WIKI_URL , OLD_WIKI_REDIRECT } from ' @src/content.constants' ;
4- const url = new URL (Astro .request .url );
5- const pathname = url .pathname ;
6- const redirectUrl = ` ${OLD_WIKI_URL }${pathname } ` ;
74---
85
96<StarlightPage frontmatter ={ {
@@ -14,28 +11,34 @@ const redirectUrl = `${OLD_WIKI_URL}${pathname}`;
1411 tagline: Astro .locals .t (' 404.text' )
1512 }
1613}} >
17- <p >Sorry, the page <strong >{ pathname } </strong > could not be found.</p >
1814 { OLD_WIKI_REDIRECT && (
1915 <p >This page doesn't exist here. You will be redirected to the old MTA Wiki in <strong ><span id = " countdown" >5</span > seconds...</p ></strong >
20- <a href = { redirectUrl } target = " _blank" rel = " noopener noreferrer" >
16+ <a href = " # " target = " _blank" rel = " noopener noreferrer" >
2117 <p >Click here to view the page on the old MTA Wiki</p >
2218 </a >
2319 )}
2420</StarlightPage >
2521
26- <script is:inline define:vars ={ { OLD_WIKI_REDIRECT , redirectUrl }} >
22+ <script is:inline define:vars ={ { OLD_WIKI_URL , OLD_WIKI_REDIRECT }} >
2723 if (!OLD_WIKI_REDIRECT) {
2824 return;
2925 }
26+ const gotoUrl = OLD_WIKI_URL + location.pathname;
3027 let countdown = 5;
3128 const el = document.getElementById('countdown');
29+ const aEl = document.querySelector('a');
30+ aEl.onclick = (e) => {
31+ e.preventDefault();
32+ clearInterval(interval);
33+ window.location.href = gotoUrl;
34+ };
3235
3336 const interval = setInterval(() => {
3437 countdown -= 1;
3538 if (el) el.textContent = countdown;
3639 if (countdown <= 0) {
3740 clearInterval(interval);
38- window.location.href = redirectUrl ;
41+ window.location.href = gotoUrl ;
3942 }
4043 }, 1000);
4144</script >
0 commit comments