File tree Expand file tree Collapse file tree 1 file changed +35
-5
lines changed Expand file tree Collapse file tree 1 file changed +35
-5
lines changed Original file line number Diff line number Diff line change 1- <script >
1+ <script lang = " ts " >
22 import { page } from ' $app/stores' ;
3+ import { onMount } from ' svelte' ;
4+ import config from ' ../config' ;
5+
6+ // guard against infinite loops
7+ let triedRedirect = false ;
8+
9+ onMount (async () => {
10+ // only for genuine 500s on a top-level slug
11+ if ($page .status === 500 && ! triedRedirect ) {
12+ const parts = $page .url .pathname .split (' /' ).filter (Boolean );
13+ const repo = parts [0 ];
14+
15+ if (repo ) {
16+ triedRedirect = true ;
17+
18+ try {
19+ const res = await fetch (` https://api.github.com/repos/${config .githubUser }/${repo } ` );
20+ if (res .ok ) {
21+ const json = await res .json ();
22+ if (json .has_pages ) {
23+ // force the browser to re-load from GitHub Pages
24+ window .location .replace (` https://${config .githubUser }.github.io/${repo }/ ` );
25+ }
26+ }
27+ } catch {
28+ // network error or rate-limit; just show your error page
29+ }
30+ }
31+ }
32+ });
333 </script >
434
535<svelte:head >
6- <title >Error | AS93</title >
7- <meta name =" description" content =" AS93 - Free & Open Source apps by Alicia Sykes" />
36+ <title >Error | AS93</title >
37+ <meta name =" description" content =" AS93 - Free & Open Source apps by Alicia Sykes" />
838</svelte:head >
939
10- <p >Oops, somethings gone a bit wrong here</p >
40+ <p >Oops, something’s gone a bit wrong here</p >
1141<h1 >{$page .status }</h1 >
1242<p class =" emoji" >😢</p >
1343{#if $page ?.error ?.message }
14- <p >{$page .error .message }</p >
44+ <p >{$page .error .message }</p >
1545{/if }
1646
1747<style >
You can’t perform that action at this time.
0 commit comments