-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(survey): Support multiple surveys #194
base: main
Are you sure you want to change the base?
Conversation
}); | ||
|
||
const selectedUser = users.find((user) => user.name === name); | ||
const ContentSection = async ({ userId }: { userId?: string }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ask @nicojs about this:
There are two options here.
Option 1: Keep it as it is, searching by name. The url will be https://.../profile-page?name=Jelle%20Buitenhuis
. However, names are not guaranteed to be unique, how would we handle that?
Option 2: Change it to userId
, which is guaranteed to be unique. The url will be https://.../profile-page?id=cm893klj4h353457
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use metadata to show the name of the user, social media apps also use this for link previews.
Quick code example would be:
const buildStaticMetadata = (): Metadata => {
return {
title: "Find the expert",
};
};
const buildTitle = (userName: string | null): string => {
if (userName === null) {
return "Find the expert";
}
return `Find the expert - ${userName}`;
};
export async function generateMetadata({
searchParams,
}: {
searchParams: Promise<{ userId?: string }>;
}): Promise<Metadata> {
const userId = (await searchParams).userId;
if (!userId) {
return buildStaticMetadata();
}
const user = await prismaClient.users.getUserById(userId);
if (!user) {
return buildStaticMetadata();
}
return {
title: buildTitle(user.name),
openGraph: {
title: buildTitle(user.name),
},
};
}
No description provided.