aboutsummaryrefslogtreecommitdiff
path: root/src/routes/+error.svelte
blob: a5cd1dee66bc28f4fab573dd4f71c91a8c275bee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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>