redirect when blog post not found
This commit is contained in:
parent
3b825fb486
commit
0ff78d56df
1 changed files with 2 additions and 0 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue