Skip to content

Commit 7e4dca1

Browse files
committed
revert error page
1 parent c94fc40 commit 7e4dca1

File tree

2 files changed

+69
-104
lines changed

2 files changed

+69
-104
lines changed

src/routes/+error.svelte

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,67 @@
1-
<script>
1+
<script lang="ts">
22
import { page } from '$app/stores';
3+
import { onMount } from 'svelte';
4+
import config from '../../config';
5+
import { fetchRepoDetails, findRepoMeta } from '../../helpers/fetchRepo';
6+
import type { Project } from '../../types/Project';
7+
import ProjectHero from '../../components/ProjectHero.svelte';
8+
9+
let gitHubPagesUrl = '';
10+
11+
export let data: { repoDetails: Project, readme: string, meta: any };
12+
13+
const reload = (url: string) => {
14+
window.location.replace(url);
15+
};
16+
17+
onMount(async () => {
18+
// only for genuine 500s on a top-level slug
19+
20+
const parts = $page.url.pathname.split('/').filter(Boolean);
21+
const repo = parts[0];
22+
if (repo) {
23+
fetchRepoDetails(config.githubUser, repo, fetch)
24+
.then((res) => {
25+
if (res && res?.id) {
26+
data.repoDetails = res as Project;
27+
data.meta = findRepoMeta(repo, config.projects) || {};
28+
console.log(data.repoDetails)
29+
if (data.repoDetails.has_pages) {
30+
gitHubPagesUrl = `https://${config.githubUser}.github.io/${repo}/`;
31+
}
32+
}
33+
})
34+
.catch((err) => {
35+
console.error('Error fetching repo details', err);
36+
});
37+
}
38+
39+
});
340
</script>
441

542
<svelte:head>
6-
<title>Error | AS93</title>
7-
<meta name="description" content="AS93 - Free & Open Source apps by Alicia Sykes" />
43+
<title>Error | AS93</title>
44+
<meta name="description" content="AS93 - Free & Open Source apps by Alicia Sykes" />
845
</svelte:head>
946

10-
<p>Oops, somethings gone a bit wrong here</p>
47+
{#if gitHubPagesUrl}
48+
<a href="{gitHubPagesUrl}" class="has-github-pages" on:click="{() => reload(gitHubPagesUrl)}" >
49+
<h3>This page has a GitHub Pages site. Click to redirect.</h3>
50+
</a>
51+
{/if}
52+
53+
{#if data.repoDetails && data.repoDetails.id}
54+
<ProjectHero project={data.repoDetails} meta={data.meta} />
55+
{/if}
56+
57+
<p>Oops, something's gone a bit wrong here</p>
1158
<h1>{$page.status}</h1>
1259
<p class="emoji">😢</p>
1360
{#if $page?.error?.message}
14-
<p>{$page.error.message}</p>
61+
<p>{$page.error.message}</p>
1562
{/if}
1663

17-
<style>
64+
<style lang="scss">
1865
h1 {
1966
font-size: 6rem;
2067
margin: 0;
@@ -29,7 +76,22 @@ h1 {
2976
p {
3077
font-size: 2rem;
3178
margin: 0;
32-
3379
text-align: center;
3480
}
81+
82+
.has-github-pages {
83+
position: fixed;
84+
top: 0;
85+
left: 0;
86+
right: 0;
87+
width: 100%;
88+
background-color: var(--primary);
89+
padding: 0.25rem;
90+
text-align: center;
91+
font-size: 1.2rem;
92+
h3 {
93+
margin: 0;
94+
font-size: 1rem;
95+
}
96+
}
3597
</style>

src/routes/[repo]/+error.svelte

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)