21 lines
486 B
JavaScript
21 lines
486 B
JavaScript
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
import { fetchUser } from '#/src/users.js';
|
|
|
|
export async function onBeforeRender(pageContext) {
|
|
const profile = await fetchUser(pageContext.routeParams.username);
|
|
|
|
if (!profile) {
|
|
throw render(404, `Cannot find user '${pageContext.routeParams.username}'.`);
|
|
}
|
|
|
|
return {
|
|
pageContext: {
|
|
title: profile.username,
|
|
pageProps: {
|
|
profile, // differentiate from authed 'user'
|
|
},
|
|
},
|
|
};
|
|
}
|