⚙ Handle non-existant categories and urls

This commit is contained in:
Ticua 2024-02-03 02:28:57 -03:00
parent c843669446
commit 3608829163
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 {
category: slug as string,
svgs: svgsByCategory