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

30 lines
623 B
JavaScript

import { fetchActors } from '#/src/actors.js';
import { curateActorsQuery } from '#/src/web/actors.js';
export async function onBeforeRender(pageContext) {
const {
actors,
countries,
cupRange,
limit,
total,
} = await fetchActors(curateActorsQuery(pageContext.urlQuery), {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 120,
order: pageContext.urlParsed.search.order?.split('.') || ['likes', 'desc'],
});
return {
pageContext: {
title: 'actors',
pageProps: {
actors,
countries,
cupRange,
limit,
total,
},
},
};
}