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

28 lines
695 B
JavaScript

import { fetchActors } from '#/src/actors.js';
export async function onBeforeRender(pageContext) {
const query = pageContext.urlParsed.search;
const { actors, limit, total } = await fetchActors({
query: query.q,
requireAvatar: Object.hasOwn(query, 'avatar'),
age: query.age?.split(',').map((age) => Number(age)),
height: query.height?.split(',').map((height) => Number(height)),
weight: query.weight?.split(',').map((weight) => Number(weight)),
}, {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 50,
});
return {
pageContext: {
title: 'actors',
pageProps: {
actors,
limit,
total,
},
},
};
}