traxxx-web/pages/search/+onBeforeRender.js

38 lines
823 B
JavaScript
Raw Normal View History

import { fetchScenes } from '#/src/scenes.js';
import { curateScenesQuery } from '#/src/web/scenes.js';
export async function onBeforeRender(pageContext) {
const searchScenes = await 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) || 30,
}, pageContext.user);
const {
scenes,
aggActors,
aggTags,
aggChannels,
total,
limit,
} = searchScenes;
return {
pageContext: {
title: `Search '${pageContext.urlParsed.search.q || ''}'`,
pageProps: {
scenes,
aggActors,
aggTags,
aggChannels,
limit,
total,
},
},
};
}