Merge pull request #241 from ticua07/add-error-404-handling

Handle non-existant categories and urls
This commit is contained in:
Pablo Hdez 2024-02-03 15:36:04 +00:00 committed by GitHub
commit 72ff8b2fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

5
src/routes/+error.svelte Normal file
View File

@ -0,0 +1,5 @@
<script lang="ts">
import { redirect } from '@sveltejs/kit';
redirect(301, '/');
</script>

View File

@ -21,6 +21,11 @@ export const load = (async ({ params }) => {
} }
}); });
// If SVGs array is empty, category can't exist
if (svgsByCategory.length === 0) {
return error(404, 'Not found');
}
return { return {
category: slug as string, category: slug as string,
svgs: svgsByCategory svgs: svgsByCategory