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

19 lines
436 B
TypeScript

import { error } from '@sveltejs/kit';
import { readTag, browsePostWithTag } from '$lib/content/contentApi';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
const tagSlug = params.tag;
const tagObj = await readTag(tagSlug);
if (!tagObj) {
throw error(404, 'Tag not found');
}
const posts = await browsePostWithTag(tagSlug);
return {
tag: tagObj,
posts: posts
};
};