benjaminpalko/src/routes/blog/[slug]/+page.server.ts
Benjamin Palko 0eb91d67dd
All checks were successful
Deployment / Deploy website (push) Successful in 2m32s
Deployment / Deploy strapi (push) Successful in 3m5s
fix strapi urls and shit
2025-05-06 12:31:44 -04:00

27 lines
603 B
TypeScript

import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async ({ locals, params }) => {
const { slug } = params;
const { strapi } = locals;
const { data: post, meta } = await strapi.Blog(slug);
return {
post: {
id: post.documentId,
image: {
url: post.Header.url,
alt: post.Header.alternativeText,
caption: post.Header.caption,
},
title: post.Title,
body: post.Body,
topics: post.Topics.map((topic: { id: string; Topic: string }) => ({
id: topic.id,
name: topic.Topic,
})),
published: post.publishedAt,
},
meta,
};
};