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