Skip to content

Commit d72484a

Browse files
committed
web/routes: refactor error handling
1 parent 5820997 commit d72484a

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

web/src/routes/+error.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script lang="ts">
22
import { onMount } from "svelte";
3-
import { page } from "$app/stores";
3+
import { page } from "$app/state";
44
import { goto } from "$app/navigation";
55
import { defaultNavPage } from "$lib/subnav";
66
77
onMount(() => {
8-
if ($page.error?.message === "Not Found") {
9-
if ($page.url.pathname.startsWith("/settings")) {
8+
if (page.error?.message === "Not Found") {
9+
if (page.url.pathname.startsWith("/settings")) {
1010
goto(defaultNavPage("settings"), { replaceState: true });
11-
} else if ($page.url.pathname.startsWith("/about")) {
11+
} else if (page.url.pathname.startsWith("/about")) {
1212
goto(defaultNavPage("about"), { replaceState: true });
1313
} else {
1414
goto("/", { replaceState: true });

web/src/routes/about/[page]/+page.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import type { ComponentType, SvelteComponent } from 'svelte';
2-
import { get } from 'svelte/store';
3-
import { error } from '@sveltejs/kit';
1+
import locale from "$lib/i18n/locale";
2+
import { get } from "svelte/store";
3+
import { error } from "@sveltejs/kit";
4+
import { defaultLocale } from "$lib/i18n/translations";
45

5-
import type { PageLoad } from './$types';
6+
import type { PageLoad } from "./$types";
7+
import type { ComponentType, SvelteComponent } from "svelte";
8+
import type { DefaultImport } from "$lib/types/generic";
69

7-
import locale from '$lib/i18n/locale';
8-
import type { DefaultImport } from '$lib/types/generic';
9-
import { defaultLocale } from '$lib/i18n/translations';
10-
11-
const pages = import.meta.glob('$i18n/*/about/*.md');
10+
const pages = import.meta.glob("$i18n/*/about/*.md");
1211

1312
export const load: PageLoad = async ({ params }) => {
1413
const getPage = (locale: string) => Object.keys(pages).find(
@@ -23,7 +22,7 @@ export const load: PageLoad = async ({ params }) => {
2322
return { component: (await componentImport()).default }
2423
}
2524

26-
error(404, 'Not found');
25+
error(404, 'Not found');
2726
};
2827

2928
export const prerender = true;

0 commit comments

Comments
 (0)