26 lines
648 B
JavaScript
26 lines
648 B
JavaScript
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
import { fetchStashByUsernameAndSlug } from '#/src/stashes.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);
|
|
|
|
return {
|
|
pageContext: {
|
|
title: `${stash.name} by ${stash.user.username}`,
|
|
pageProps: {
|
|
stash,
|
|
},
|
|
},
|
|
};
|
|
} catch (error) {
|
|
if (error instanceof HttpError) {
|
|
throw render(error.httpCode, error.message);
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|