36 lines
1019 B
JavaScript
36 lines
1019 B
JavaScript
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
import { fetchActorsById } from '#/src/actors.js';
|
|
import { fetchScenes } from '#/src/scenes.js';
|
|
import { curateScenesQuery } from '#/src/web/scenes.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
const [[actor], actorScenes] = await Promise.all([
|
|
fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user),
|
|
fetchScenes(await curateScenesQuery({
|
|
...pageContext.urlQuery,
|
|
scope: pageContext.routeParams.scope || 'latest',
|
|
actorId: Number(pageContext.routeParams.actorId),
|
|
tagFilter: pageContext.tagFilter,
|
|
}), {
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
limit: Number(pageContext.urlParsed.search.limit) || 30,
|
|
aggregate: true,
|
|
}, pageContext.user),
|
|
]);
|
|
|
|
if (!actor) {
|
|
throw render(404, `Cannot find actor '${pageContext.routeParams.actorId}'.`);
|
|
}
|
|
|
|
return {
|
|
pageContext: {
|
|
title: actor.name,
|
|
pageProps: {
|
|
actor,
|
|
...actorScenes,
|
|
},
|
|
},
|
|
};
|
|
}
|