Reinitialized commit. Update and actors overview with some filters.
This commit is contained in:
27
pages/actors/+onBeforeRender.js
Normal file
27
pages/actors/+onBeforeRender.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user