42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
import { getRandomCampaigns } from '#/src/campaigns.js';
|
|
import { fetchMovies } from '#/src/movies.js';
|
|
import { curateMoviesQuery } from '#/src/web/movies.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
const [
|
|
movieResults,
|
|
campaigns,
|
|
] = await Promise.all([
|
|
fetchMovies(await curateMoviesQuery({
|
|
...pageContext.urlQuery,
|
|
scope: pageContext.routeParams.scope || 'latest',
|
|
}), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 50,
|
|
dedupe: true,
|
|
}, pageContext.user, {
|
|
restriction: pageContext.geo.restriction,
|
|
}),
|
|
// same banner shapes as the scenes page header and footer
|
|
getRandomCampaigns([
|
|
{ minRatio: 3 },
|
|
{ minRatio: 1.5 },
|
|
], { tagFilter: pageContext.tagFilter }),
|
|
]);
|
|
|
|
const [metaCampaign, paginationCampaign] = campaigns;
|
|
|
|
return {
|
|
pageContext: {
|
|
title: 'Movies',
|
|
pageProps: {
|
|
...movieResults,
|
|
},
|
|
campaigns: {
|
|
meta: metaCampaign,
|
|
pagination: paginationCampaign,
|
|
},
|
|
},
|
|
};
|
|
}
|