Skip to content

Commit 7a45f21

Browse files
committed
feat: add support for custom pages
1 parent 5332ed8 commit 7a45f21

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

src/pages/NotFound.svelte

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,50 @@
11
<script lang="ts">
22
import { Link } from "@/lib/routing/index.js";
3+
import { createQuery } from "@tanstack/svelte-query";
4+
import { ExtensionsQueryKey } from "@/constants/extensions";
5+
import { getExtensions } from "@/lib/extensions/get-extensions";
6+
import type { ManifestType } from "@/types/extensions/manifest.type";
7+
import { BaseURL } from "@/constants/app";
8+
9+
const extensions = createQuery({
10+
// will be re-fetched on plugin list update
11+
"queryKey": ExtensionsQueryKey,
12+
"queryFn" : () => {
13+
const currentExtensions = getExtensions({
14+
"local": true,
15+
});
16+
17+
return Object.entries(currentExtensions);
18+
},
19+
});
20+
const currentPath = window.location.pathname;
21+
const isReservedByExtensionPage = $derived(
22+
($extensions.data ?? [])
23+
.filter((filtering: [string, ManifestType]) => {
24+
return (filtering[1].pages ?? [])
25+
// initially pages are defined without the base url
26+
.map((page: string) => BaseURL + page)
27+
.includes(currentPath);
28+
}).length > 0,
29+
);
330
</script>
431

5-
<!-- if browser supports `svh` (firefox 101+, chrome 108+) -->
6-
<!-- then page will use `svh` as its max height -->
7-
<!-- otherwise `vh` will be applied -->
8-
<div class="h-screen w-full flex flex-col items-center justify-center gap-2 max-h-svh">
9-
<p class="text-4xl font-600">
10-
404
11-
</p>
12-
<p class="text-2xl font-600">
13-
Not Found
14-
</p>
15-
<Link
16-
class="mt-2 cursor-pointer rounded-md bg-rose-500 px-4 py-2 transition-[opacity] focus:cursor-default focus:opacity-70"
17-
href="/"
18-
>
19-
Home
20-
</Link>
21-
</div>
32+
{#if !isReservedByExtensionPage}
33+
<!-- if browser supports `svh` (firefox 101+, chrome 108+) -->
34+
<!-- then page will use `svh` as its max height -->
35+
<!-- otherwise `vh` will be applied -->
36+
<div class="h-screen w-full flex flex-col items-center justify-center gap-2 max-h-svh">
37+
<p class="text-4xl font-600">
38+
404
39+
</p>
40+
<p class="text-2xl font-600">
41+
Not Found
42+
</p>
43+
<Link
44+
class="mt-2 cursor-pointer rounded-md bg-rose-500 px-4 py-2 transition-[opacity] focus:cursor-default focus:opacity-70"
45+
href="/"
46+
>
47+
Home
48+
</Link>
49+
</div>
50+
{/if}

0 commit comments

Comments
 (0)