aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-24 07:36:21 -0800
committerFuwn <[email protected]>2023-12-24 07:36:21 -0800
commit2821bbdcd8e9f76632dff9ddd2b7e63c15be31c7 (patch)
treea1ccf36c77bfe8d00b0c31252810c79aafda6e72 /src
parentfeat(layout): redirect to login point (diff)
downloaddue.moe-2821bbdcd8e9f76632dff9ddd2b7e63c15be31c7.tar.xz
due.moe-2821bbdcd8e9f76632dff9ddd2b7e63c15be31c7.zip
feat(error): route predict
Diffstat (limited to 'src')
-rw-r--r--src/routes/+error.svelte40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte
new file mode 100644
index 00000000..a5cd1dee
--- /dev/null
+++ b/src/routes/+error.svelte
@@ -0,0 +1,40 @@
+<script lang="ts">
+ import { browser } from '$app/environment';
+ import levenshtein from 'fast-levenshtein';
+
+ $: suggestion = (() => {
+ let closest = '';
+ let lowestDistance = Infinity;
+
+ [
+ 'birthdays',
+ 'completed',
+ 'schedule',
+ 'settings',
+ 'tools',
+ 'updates',
+ 'user',
+ 'wrapped',
+ '...'
+ ].forEach((path) => {
+ let distance = levenshtein.get(browser ? window.location.pathname : '...', path);
+
+ if (distance < lowestDistance) {
+ lowestDistance = distance;
+ closest = path;
+ }
+ });
+
+ return closest;
+ })();
+</script>
+
+<p>Page not found.</p>
+
+<blockquote>
+ Did you mean "<a
+ href={suggestion}
+ style={suggestion === '...' ? 'pointer-events: none; color: inherit;' : ''}
+ >{suggestion.charAt(0).toUpperCase() + suggestion.slice(1)}</a
+ >"?
+</blockquote>