Added basic actor page with scenes and co-star filtering.

This commit is contained in:
2024-01-07 06:13:40 +01:00
parent ffcb77ab45
commit e32a366fff
14 changed files with 476 additions and 144 deletions

View File

@@ -1,11 +1,45 @@
<template>
<div class="page">
<h2>Actor</h2>
<div class="bio">
<img
v-if="actor.avatar"
:src="actor.avatar.isS3 ? `https://cdndev.traxxx.me/${actor.avatar.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:style="{ 'background-image': actor.avatar.isS3 ? `url(https://cdndev.traxxx.me/${actor.avatar.lazy})` : `url(/media/${actor.avatar.lazy})` }"
class="avatar"
>
<h2 class="name">{{ actor.name }}</h2>
</div>
<Scenes />
</div>
</template>
<script setup>
import { inject } from 'vue';
const { routeParams } = inject('pageContext');
import Scenes from '#/components/scenes/scenes.vue';
const pageContext = inject('pageContext');
const { pageProps } = pageContext;
const { actor } = pageProps;
</script>
<style scoped>
.bio {
display: flex;
padding: 1rem;
background: var(--grey-dark-40);
color: var(--text-light);
}
.name {
margin: 0;
}
.avatar {
height: 10rem;
margin-right: 1rem;
}
</style>

View 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,
},
},
};
}

View File

@@ -1 +1,23 @@
export default '/actor/@actorId/*';
import { match } from 'path-to-regexp';
// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions
const path = '/actor/:actorId/:actorSlug?/:scope?/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
const matched = urlMatch(pageContext.urlPathname);
if (matched) {
return {
routeParams: {
actorId: matched.params.actorId,
actorSlug: matched.params.actorSlug,
scope: matched.params.scope || 'latest',
page: matched.params.page || '1',
path,
},
};
}
return false;
};

View File

@@ -2,6 +2,7 @@
<div>
<Scenes
:scenes="scenes"
:show-filters="false"
/>
</div>
</template>
@@ -9,7 +10,7 @@
<script setup>
import { inject } from 'vue';
import Scenes from '../../components/scenes/scenes.vue';
import Scenes from '#/components/scenes/scenes.vue';
const { pageProps } = inject('pageContext');
const { scenes } = pageProps;

View File

@@ -1,21 +1,13 @@
import { fetchLatest, fetchUpcoming, fetchNew } from '#/src/scenes.js';
async function fetchScenes(scope, page, limit) {
if (scope === 'new') {
return fetchNew(page, { limit });
}
if (scope === 'upcoming') {
return fetchUpcoming(page, { limit });
}
return fetchLatest(page, { limit });
}
import { fetchScenes } from '#/src/scenes.js';
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);
const { scenes, limit, total } = await fetchScenes({
scope: pageContext.routeParams.scope || 'latest',
}, {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 30,
aggregate: false,
});
return {
pageContext: {