traxxx-web/pages/updates/+onBeforeRender.js

31 lines
692 B
JavaScript
Raw Normal View History

2024-01-04 00:49:16 +00:00
import { fetchLatest, fetchUpcoming, fetchNew } from '#/src/scenes.js';
async function fetchScenes(scope, page, limit) {
if (scope === 'new') {
return fetchNew(page, { limit });
}
if (scope === 'upcoming') {
return fetchUpcoming(page, { limit });
}
return fetchLatest(page, { limit });
}
export async function onBeforeRender(pageContext) {
const { scenes, limit, total } = await fetchScenes(pageContext.routeParams.scope, Number(pageContext.routeParams.page) || 1, Number(pageContext.urlParsed.search.limit) || 30);
// console.log(scenes);
return {
pageContext: {
title: pageContext.routeParams.scope,
pageProps: {
scenes,
limit,
total,
},
},
};
}