2024-02-29 05:00:12 +00:00
|
|
|
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
|
|
|
|
2024-02-29 04:08:54 +00:00
|
|
|
import { fetchUser } from '#/src/users.js';
|
|
|
|
|
|
|
|
export async function onBeforeRender(pageContext) {
|
2024-03-26 02:00:50 +00:00
|
|
|
const profile = await fetchUser(pageContext.routeParams.username, {}, pageContext.user);
|
2024-02-29 04:08:54 +00:00
|
|
|
|
2024-03-27 01:28:21 +00:00
|
|
|
// console.log(profile);
|
|
|
|
|
2024-02-29 05:00:12 +00:00
|
|
|
if (!profile) {
|
|
|
|
throw render(404, `Cannot find user '${pageContext.routeParams.username}'.`);
|
|
|
|
}
|
|
|
|
|
2024-02-29 04:08:54 +00:00
|
|
|
return {
|
|
|
|
pageContext: {
|
|
|
|
title: profile.username,
|
|
|
|
pageProps: {
|
|
|
|
profile, // differentiate from authed 'user'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|