diff options
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/+error.svelte | 3 | ||||
| -rw-r--r-- | src/routes/tools/+page.svelte | 23 |
2 files changed, 23 insertions, 3 deletions
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' ]); </script> 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)); </script> <blockquote> @@ -32,7 +42,18 @@ </select> </blockquote> -{#if tool === 'default'} +{#if !Object.keys(tools).includes(tool)} + <p>Tool not found.</p> + + <blockquote> + Did you mean "<a + href={`?tool=${suggestion}`} + style={suggestion === '...' ? 'pointer-events: none; color: inherit;' : ''} + > + {suggestion === '...' ? '...' : tools[suggestion]}</a + >"? + </blockquote> +{:else if tool === 'default'} Select a tool to continue. {:else if tool === 'activity_history'} <ActivityHistory user={data.user} /> |