redirect when blog post not found

This commit is contained in:
cirroskais 2024-04-22 03:41:34 -04:00
parent 3b825fb486
commit 0ff78d56df
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D

View file

@ -6,6 +6,7 @@
import { markedEmoji } from 'marked-emoji'; import { markedEmoji } from 'marked-emoji';
import blog from '$lib/blog.json'; import blog from '$lib/blog.json';
import { goto } from '$app/navigation';
export let data; export let data;
@ -21,6 +22,7 @@
); );
onMount(async () => { onMount(async () => {
if (!thisPost?.title) return goto('/blog');
const response = await fetch(`/blog/${data.slug}.md`); const response = await fetch(`/blog/${data.slug}.md`);
const body = await response.text(); const body = await response.text();
markdown = await marked.parse(body); markdown = await marked.parse(body);