aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Error/path.ts2
-rw-r--r--src/routes/+error.svelte3
-rw-r--r--src/routes/tools/+page.svelte23
3 files changed, 24 insertions, 4 deletions
diff --git a/src/lib/Error/path.ts b/src/lib/Error/path.ts
index 50874a12..f493726b 100644
--- a/src/lib/Error/path.ts
+++ b/src/lib/Error/path.ts
@@ -4,7 +4,7 @@ export const closest = (path: string, suggestions: string[]) => {
let closest = '';
let lowestDistance = Infinity;
- suggestions.forEach((suggestion) => {
+ [...suggestions, '...'].forEach((suggestion) => {
const distance = levenshtein.get(path, suggestion);
if (distance < lowestDistance) {
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} />