Skip to content

Commit

Permalink
Added custom error page so GH pages doesn't fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
gchartier committed Aug 14, 2024
1 parent 1b60a3b commit c5edaa6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
29 changes: 29 additions & 0 deletions src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script>
import { page } from "$app/stores";
import Waves from "$lib/components/Waves.svelte";
let heading = $page.status === 404 ? "404" : "Error";
let errorMessage =
$page.error && $page.error.message.includes("Error: ")
? "An unknown error occurred"
: $page.error?.message;
let notFoundMessage =
$page.error?.message === "Not Found" ? "Page not found" : $page.error?.message;
</script>
<div
class="flex flex-col min-h-full h-full flex-grow justify-center items-center text-2xl overflow-hidden"
>
<div
class="flex flex-col bg-gradient-to-b from-primary to-accentLight justify-between items-center"
>
<div class="text-center space-y-2 items-center justify-center h-full mt-64">
<h1 class="text-5xl lg:text-9xl font-black">{heading}</h1>
<p class="text-2xl lg:text-4xl text-muted-foreground">
{$page.status === 404 ? notFoundMessage : errorMessage}
</p>
</div>
<Waves />
<div class="bg-accent h-64 w-full"></div>
</div>
</div>
16 changes: 10 additions & 6 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<script>
import '../app.pcss';
import Footer from '$lib/sections/Footer.svelte';
import Header from '$lib/sections/Header.svelte';
import "../app.pcss";
import Footer from "$lib/sections/Footer.svelte";
import Header from "$lib/sections/Header.svelte";
</script>

<Header />
<slot />
<Footer />
<div class="flex flex-col min-h-screen">
<Header />
<main class="flex-grow bg-accent">
<slot />
</main>
<Footer />
</div>
4 changes: 3 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const config = {
preprocess: vitePreprocess(),

kit: {
adapter: adapter(),
adapter: adapter({
fallback: "404.html",
}),
paths: {
base: process.env.NODE_ENV === "production" ? process.env.BASE_PATH : "",
},
Expand Down

0 comments on commit c5edaa6

Please sign in to comment.