27 lines
648 B
JavaScript
27 lines
648 B
JavaScript
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
import { fetchActors } from '#/src/actors.js';
|
|
import verifyAbility from '#/utils/verify-ability.js';
|
|
|
|
export default async function onBeforeRender(pageContext) {
|
|
if (!pageContext.user || !verifyAbility(pageContext.user, 'actor', 'merge')) {
|
|
throw render(404);
|
|
}
|
|
|
|
const { actors } = await fetchActors({
|
|
query: pageContext.urlParsed.search.q,
|
|
}, {
|
|
limit: 100,
|
|
// order: pageContext.urlParsed.search.order?.split('.') || ['likes', 'desc'],
|
|
}, pageContext.user);
|
|
|
|
return {
|
|
pageContext: {
|
|
title: 'Actors',
|
|
pageProps: {
|
|
actors,
|
|
},
|
|
},
|
|
};
|
|
}
|