mirror of
https://github.com/BradNut/personal-website-sveltekit
synced 2025-09-08 23:20:18 +00:00
24 lines
586 B
TypeScript
24 lines
586 B
TypeScript
import type { PageServerLoad } from './$types';
|
|
import type { Article } from '$root/lib/types/article';
|
|
|
|
export type ArticlePageLoad = {
|
|
articles: Article[];
|
|
currentPage: number;
|
|
totalPages: number;
|
|
limit: number;
|
|
totalArticles: number;
|
|
};
|
|
|
|
export const load: PageServerLoad = async ({ fetch, params }) => {
|
|
const { page } = params;
|
|
const resp = await fetch(`/api/articles?page=${page}`);
|
|
const { articles, currentPage, totalPages, limit, totalArticles }: ArticlePageLoad =
|
|
await resp.json();
|
|
return {
|
|
articles,
|
|
currentPage,
|
|
totalPages,
|
|
limit,
|
|
totalArticles
|
|
};
|
|
};
|