36 lines
698 B
JavaScript
36 lines
698 B
JavaScript
import { fetchMovies } from '#/src/movies.js';
|
|
import { curateMoviesQuery } from '#/src/web/movies.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
const movieResults = await fetchMovies(await curateMoviesQuery({
|
|
...pageContext.urlQuery,
|
|
scope: pageContext.routeParams.scope || 'latest',
|
|
}), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 50,
|
|
}, pageContext.user);
|
|
|
|
const {
|
|
movies,
|
|
aggActors,
|
|
aggTags,
|
|
aggChannels,
|
|
total,
|
|
limit,
|
|
} = movieResults;
|
|
|
|
return {
|
|
pageContext: {
|
|
title: 'Movies',
|
|
pageProps: {
|
|
movies,
|
|
aggActors,
|
|
aggTags,
|
|
aggChannels,
|
|
limit,
|
|
total,
|
|
},
|
|
},
|
|
};
|
|
}
|