add 404 page
This commit is contained in:
parent
859c34fd82
commit
00300167eb
14
src/routes/404/+page.svelte
Normal file
14
src/routes/404/+page.svelte
Normal file
@ -0,0 +1,14 @@
|
||||
<style>
|
||||
h1 {
|
||||
margin-top: 6rem;
|
||||
}
|
||||
|
||||
h1, p {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<h1>404</h1>
|
||||
|
||||
<p>That page doesn't exist. Sorry!</p>
|
@ -2,18 +2,23 @@ import { error } from '@sveltejs/kit';
|
||||
|
||||
|
||||
export async function load({ url, params, data }) {
|
||||
let post;
|
||||
try {
|
||||
let post = await import(`../_posts/${params.slug}.svx`);
|
||||
post.metadata.slug = params.slug;
|
||||
post.metadata.prev = data.prev;
|
||||
post.metadata.next = data.next;
|
||||
return {
|
||||
post: post.default,
|
||||
}
|
||||
post = await import(`../_posts/${params.slug}.svx`);
|
||||
}
|
||||
catch (err) {
|
||||
// throw error(404, `Not found: ${url.pathname}`);
|
||||
console.log(err);
|
||||
throw err;
|
||||
if (err.message.match(/Unknown variable dynamic import/)) {
|
||||
throw error(404, `Not found: ${url.pathname}`);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
post.metadata.slug = params.slug;
|
||||
post.metadata.prev = data.prev;
|
||||
post.metadata.next = data.next;
|
||||
return {
|
||||
post: post.default,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user