Исправил 404 для несуществующих заметок
This commit is contained in:
parent
aecbdca261
commit
2781b8ea2a
1 changed files with 7 additions and 1 deletions
|
|
@ -1,7 +1,13 @@
|
|||
import { resolveBlogPath, THUMBNAIL_DEFAULT } from "$src/lib/util/Blogs.js";
|
||||
import { error } from "@sveltejs/kit";
|
||||
|
||||
export async function load({ params }) {
|
||||
const post = await import(`$src/blogs/${params.slug}.md`);
|
||||
let post: any
|
||||
try {
|
||||
post = await import(`$src/blogs/${params.slug}.md`);
|
||||
} catch (ex) {
|
||||
error(404);
|
||||
}
|
||||
const blogPost: App.BlogPost = post.metadata;
|
||||
const thumbnail = resolveBlogPath(params.slug, blogPost.thumbnail ?? THUMBNAIL_DEFAULT);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue