I have created two test blog posts in our dashboard which I want to test in our SvelteKit app. Following the guide, I am able to generate the UID from the pages, but when I type in any param for a page that does not exist, it still renders instead of redirecting to a 404 with a simple try-catch. Could use some guidance on this. Code below as well as screenshot.
<script context="module">
import Client from "../../../utils/client";
export async function load({ page }) {
try {
const { uid } = page.params;
const document = await Client.getByUID("blog_post", uid);
return {
props: {
document,
uid,
},
};
} catch (error) {
return {
status: 404,
error: "Post not found",
};
}
}
</script>
<script>
export let document, uid;
console.log(uid);
console.log(document);
</script>
<h1>{uid}</h1>
