Reinitialized commit. Update and actors overview with some filters.
This commit is contained in:
30
pages/updates/+onBeforeRender.js
Normal file
30
pages/updates/+onBeforeRender.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { fetchLatest, fetchUpcoming, fetchNew } from '../../src/scenes';
|
||||
|
||||
async function fetchScenes(scope, page, limit) {
|
||||
if (scope === 'new') {
|
||||
return fetchNew(page, { limit });
|
||||
}
|
||||
|
||||
if (scope === 'upcoming') {
|
||||
return fetchUpcoming(page, { limit });
|
||||
}
|
||||
|
||||
return fetchLatest(page, { limit });
|
||||
}
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
const { scenes, limit, total } = await fetchScenes(pageContext.routeParams.scope, Number(pageContext.routeParams.page) || 1, Number(pageContext.urlParsed.search.limit) || 30);
|
||||
|
||||
// console.log(scenes);
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: pageContext.routeParams.scope,
|
||||
pageProps: {
|
||||
scenes,
|
||||
limit,
|
||||
total,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user