36 lines
795 B
JavaScript
36 lines
795 B
JavaScript
import { render } from 'vike/abort';
|
|
|
|
import { fetchSceneRevisions } from '#/src/scenes.js';
|
|
import verifyAbility from '#/utils/verify-ability.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
if (!pageContext.user || !verifyAbility(pageContext.user, 'scene', 'update')) {
|
|
throw render(404);
|
|
}
|
|
|
|
const {
|
|
revisions,
|
|
total: revisionTotal,
|
|
actors,
|
|
tags,
|
|
movies,
|
|
} = await fetchSceneRevisions(null, {
|
|
isFinalized: Object.hasOwn(pageContext.urlParsed.search, 'final'),
|
|
limit: Number(pageContext.urlParsed.search.limit) || 100,
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
}, pageContext.user);
|
|
|
|
return {
|
|
pageContext: {
|
|
title: pageContext.routeParams.section,
|
|
pageProps: {
|
|
revisions,
|
|
revisionTotal,
|
|
actors,
|
|
tags,
|
|
movies,
|
|
},
|
|
},
|
|
};
|
|
}
|