Added basic actor page with scenes and co-star filtering.
This commit is contained in:
35
pages/actors/@actorId/+onBeforeRender.js
Normal file
35
pages/actors/@actorId/+onBeforeRender.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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] = await fetchActorsById([Number(pageContext.routeParams.actorId)]);
|
||||
|
||||
const {
|
||||
scenes,
|
||||
actors,
|
||||
total,
|
||||
limit,
|
||||
} = await fetchScenes(curateScenesQuery({
|
||||
...pageContext.urlQuery,
|
||||
scope: pageContext.routeParams.scope || 'latest',
|
||||
actorId: Number(pageContext.routeParams.actorId),
|
||||
}), {
|
||||
page: Number(pageContext.routeParams.page) || 1,
|
||||
limit: Number(pageContext.urlParsed.search.limit) || 30,
|
||||
aggregate: true,
|
||||
});
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: actor.name,
|
||||
pageProps: {
|
||||
actor,
|
||||
actors,
|
||||
scenes,
|
||||
total,
|
||||
limit,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user