Shallie/src/routes/author/[author]/+page.ts

20 lines
470 B
TypeScript

import { readAuthor, browsePostWithAuthor } from '$lib/content/contentApi';
import { error } from '@sveltejs/kit';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
const authorSlug = params.author;
const authorObj = await readAuthor(authorSlug);
if (!authorObj) {
throw error(404, 'Author not found');
}
const posts = await browsePostWithAuthor(authorSlug);
return {
author: authorObj,
posts: posts
};
};