Added visibility toggle to stash tile. Collapsed stash page directory structure.

This commit is contained in:
2024-03-26 03:00:50 +01:00
parent f6b50cc732
commit ce4b9e7d40
15 changed files with 127 additions and 30 deletions

View File

@@ -0,0 +1,10 @@
<template>
<Stash>
<Scenes />
</Stash>
</template>
<script setup>
import Stash from '#/components/stashes/stash.vue';
import Scenes from '#/components/scenes/scenes.vue';
</script>

View File

@@ -0,0 +1,51 @@
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { fetchStashByUsernameAndSlug } from '#/src/stashes.js';
import { fetchScenes } from '#/src/scenes.js';
import { curateScenesQuery } from '#/src/web/scenes.js';
import { HttpError } from '#/src/errors.js';
export async function onBeforeRender(pageContext) {
try {
const stash = await fetchStashByUsernameAndSlug(pageContext.routeParams.username, pageContext.routeParams.stashSlug, pageContext.user);
const stashScenes = await fetchScenes(await curateScenesQuery({
...pageContext.urlQuery,
scope: pageContext.routeParams.scope || 'stashed',
stashId: stash.id,
}), {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 30,
}, pageContext.user);
const {
scenes,
aggActors,
aggTags,
aggChannels,
total,
limit,
} = stashScenes;
return {
pageContext: {
title: `${stash.name} by ${stash.user.username}`,
pageProps: {
stash,
scenes,
aggActors,
aggTags,
aggChannels,
total,
limit,
},
},
};
} catch (error) {
if (error instanceof HttpError) {
throw render(error.httpCode, error.message);
}
throw error;
}
}

View File

@@ -0,0 +1,24 @@
import { match } from 'path-to-regexp';
// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions
const path = '/stash/:username/:stashSlug/:domain?/:scope?/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
const matched = urlMatch(pageContext.urlPathname);
if (matched) {
return {
routeParams: {
username: matched.params.username,
stashSlug: matched.params.stashSlug,
domain: matched.params.domain || 'scenes',
scope: matched.params.scope || 'stashed',
page: matched.params.page || '1',
path,
},
};
}
return false;
};