68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
import { fetchScenes } from '#/src/scenes.js';
|
|
import { fetchActors } from '#/src/actors.js';
|
|
import { fetchMovies } from '#/src/movies.js';
|
|
import { curateScenesQuery } from '#/src/web/scenes.js';
|
|
import { curateActorsQuery } from '#/src/web/actors.js';
|
|
import { curateMoviesQuery } from '#/src/web/movies.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
const [searchScenes, searchActors, searchMovies] = await Promise.all([
|
|
fetchScenes(await curateScenesQuery({
|
|
...pageContext.urlQuery,
|
|
query: pageContext.urlParsed.search.q,
|
|
scope: pageContext.urlParsed.search.scope || 'results',
|
|
tagFilter: pageContext.tagFilter,
|
|
}), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 15,
|
|
}, pageContext.user),
|
|
fetchActors(curateActorsQuery(pageContext.urlQuery), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 10,
|
|
order: ['results', 'desc'],
|
|
}, pageContext.user),
|
|
fetchMovies(await curateMoviesQuery({
|
|
...pageContext.urlQuery,
|
|
scope: pageContext.routeParams.scope || 'results',
|
|
}), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 5,
|
|
}, pageContext.user),
|
|
]);
|
|
|
|
const {
|
|
scenes,
|
|
aggActors,
|
|
aggTags,
|
|
aggChannels,
|
|
total: sceneTotal,
|
|
} = searchScenes;
|
|
|
|
const {
|
|
actors,
|
|
total: actorTotal,
|
|
} = searchActors;
|
|
|
|
const {
|
|
movies,
|
|
total: movieTotal,
|
|
} = searchMovies;
|
|
|
|
return {
|
|
pageContext: {
|
|
title: `Search '${pageContext.urlParsed.search.q || ''}'`,
|
|
pageProps: {
|
|
actors,
|
|
scenes,
|
|
movies,
|
|
aggActors,
|
|
aggTags,
|
|
aggChannels,
|
|
sceneTotal,
|
|
actorTotal,
|
|
movieTotal,
|
|
},
|
|
},
|
|
};
|
|
}
|