2024-02-27 00:20:15 +00:00
|
|
|
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,
|
2024-03-25 01:08:09 +00:00
|
|
|
}, pageContext.user);
|
2024-02-27 00:20:15 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
pageContext: {
|
|
|
|
title: 'Movies',
|
|
|
|
pageProps: {
|
2024-08-17 23:36:37 +00:00
|
|
|
...movieResults,
|
2024-02-27 00:20:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|