Reinitialized commit. Update and actors overview with some filters.
This commit is contained in:
16
pages/updates/+Page.vue
Normal file
16
pages/updates/+Page.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<div>
|
||||
<Scenes
|
||||
:scenes="scenes"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
import Scenes from '../../components/scenes/scenes.vue';
|
||||
|
||||
const { pageProps } = inject('pageContext');
|
||||
const { scenes } = pageProps;
|
||||
</script>
|
||||
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,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
34
pages/updates/+route.js
Normal file
34
pages/updates/+route.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { resolveRoute } from 'vike/routing';
|
||||
|
||||
export default (pageContext) => {
|
||||
{
|
||||
const result = resolveRoute('/updates/@scope/@page', pageContext.urlPathname);
|
||||
|
||||
if (result.match) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const result = resolveRoute('/updates/@scope', pageContext.urlPathname);
|
||||
|
||||
if (result.match) {
|
||||
result.routeParams.page = '1';
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const result = resolveRoute('/updates', pageContext.urlPathname);
|
||||
|
||||
if (result.match) {
|
||||
result.routeParams.scope = 'latest';
|
||||
result.routeParams.page = '1';
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user