2024-03-25 01:08:09 +00:00
|
|
|
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
|
2024-01-07 05:13:40 +00:00
|
|
|
import { fetchActorsById } from '#/src/actors.js';
|
|
|
|
import { fetchScenes } from '#/src/scenes.js';
|
|
|
|
import { curateScenesQuery } from '#/src/web/scenes.js';
|
|
|
|
|
|
|
|
export async function onBeforeRender(pageContext) {
|
2024-01-08 01:21:57 +00:00
|
|
|
const [[actor], actorScenes] = await Promise.all([
|
2024-03-21 01:54:05 +00:00
|
|
|
fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user),
|
2024-01-08 01:21:57 +00:00
|
|
|
fetchScenes(await curateScenesQuery({
|
|
|
|
...pageContext.urlQuery,
|
|
|
|
scope: pageContext.routeParams.scope || 'latest',
|
|
|
|
actorId: Number(pageContext.routeParams.actorId),
|
2024-04-02 03:55:53 +00:00
|
|
|
tagFilter: pageContext.tagFilter,
|
2024-01-08 01:21:57 +00:00
|
|
|
}), {
|
|
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
|
|
limit: Number(pageContext.urlParsed.search.limit) || 30,
|
|
|
|
aggregate: true,
|
2024-03-21 01:54:05 +00:00
|
|
|
}, pageContext.user),
|
2024-01-08 01:21:57 +00:00
|
|
|
]);
|
2024-01-07 05:13:40 +00:00
|
|
|
|
2024-03-25 01:08:09 +00:00
|
|
|
if (!actor) {
|
|
|
|
throw render(404, `Cannot find actor '${pageContext.routeParams.actorId}'.`);
|
|
|
|
}
|
|
|
|
|
2024-01-07 05:13:40 +00:00
|
|
|
return {
|
|
|
|
pageContext: {
|
|
|
|
title: actor.name,
|
|
|
|
pageProps: {
|
|
|
|
actor,
|
2024-08-17 23:36:37 +00:00
|
|
|
...actorScenes,
|
2024-01-07 05:13:40 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|