From 984e209b29d2cf825ffe22f82d67216224791800 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 25 Dec 2023 00:06:56 -0800 Subject: feat(tools): suggest path for error --- src/routes/+error.svelte | 3 +-- src/routes/tools/+page.svelte | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src/routes') diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index 584d4ec0..30723970 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -10,8 +10,7 @@ 'tools', 'updates', 'user', - 'wrapped', - '...' + 'wrapped' ]); diff --git a/src/routes/tools/+page.svelte b/src/routes/tools/+page.svelte index a7fd35d1..a6e2aedb 100644 --- a/src/routes/tools/+page.svelte +++ b/src/routes/tools/+page.svelte @@ -6,12 +6,21 @@ import CharacterBirthdays from '$lib/Tools/Birthdays.svelte'; import { page } from '$app/stores'; import SequelSpy from '$lib/Tools/SequelSpy.svelte'; + import { closest } from '$lib/Error/path'; export let data; const urlParameters = browser ? new URLSearchParams(window.location.search) : null; let tool = browser && urlParameters?.size !== 0 ? urlParameters?.get('tool') || 'default' : 'default'; + const tools: { [key: string]: string } = { + default: 'Tool', + todays_character_birthdays: "Today's Character Birthdays", + activity_history: 'Activity History', + wrapped: 'Wrapped', + episode_discussion_collector: 'Episode Discussion Collector (Beta)', + sequel_spy: 'Sequel Spy' + }; $: { if (browser) { @@ -19,6 +28,7 @@ history.replaceState(null, '', `?${$page.url.searchParams.toString()}`); } } + $: suggestion = closest(browser ? tool : '...', Object.keys(tools));
@@ -32,7 +42,18 @@
-{#if tool === 'default'} +{#if !Object.keys(tools).includes(tool)} +

Tool not found.

+ +
+ Did you mean " + {suggestion === '...' ? '...' : tools[suggestion]}"? +
+{:else if tool === 'default'} Select a tool to continue. {:else if tool === 'activity_history'} -- cgit v1.2.3