mirror of
https://github.com/LukeHagar/Sveltey.git
synced 2025-12-06 12:47:44 +00:00
upadting lock, and blog post load function
This commit is contained in:
2476
package-lock.json
generated
2476
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,10 @@
|
|||||||
// src/routes/blog/[slug]/+page.server.ts
|
// src/routes/blog/[slug]/+page.server.ts
|
||||||
import { getAllPosts } from '$lib/blog';
|
import { getAllPosts, getPostBySlug } from '$lib/blog';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const load = async ({ params }) => {
|
export const load = async ({ params }) => {
|
||||||
// Get only the metadata for the post
|
// Get only the metadata for the post
|
||||||
const posts = await getAllPosts();
|
const post = await getPostBySlug(params.slug);
|
||||||
const post = posts.find(p => p.slug === params.slug);
|
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
throw error(404, 'Blog post not found');
|
throw error(404, 'Blog post not found');
|
||||||
|
|||||||
Reference in New Issue
Block a user