Skip to content

Commit d9c6155

Browse files
committed
process slug with backward compatibility
1 parent 67ae62b commit d9c6155

File tree

1 file changed

+21
-2
lines changed
  • app/[locale]/(user)/publishers/[publisherSlug]

1 file changed

+21
-2
lines changed

app/[locale]/(user)/publishers/[publisherSlug]/page.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@ const userInfo = graphql(`
1717
}
1818
}
1919
`);
20+
21+
const extractPublisherId = (publisherSlug: any) => {
22+
// If the param contains an underscore, split and take the last part
23+
if (publisherSlug.includes('_')) {
24+
return publisherSlug.split('_').pop();
25+
}
26+
27+
// Otherwise, return the param as is (it's already just the ID)
28+
return publisherSlug;
29+
};
30+
2031
export async function generateMetadata({
2132
params,
2233
}: {
2334
params: { publisherSlug: string };
2435
}): Promise<Metadata> {
25-
const data = await GraphQL(userInfo, {}, { userId: params.publisherSlug });
36+
const data = await GraphQL(
37+
userInfo,
38+
{},
39+
{ userId: extractPublisherId(params.publisherSlug) }
40+
);
2641

2742
const user = data.userById;
2843

@@ -58,5 +73,9 @@ export default function PublisherPage({
5873
}: {
5974
params: { publisherSlug: string };
6075
}) {
61-
return <PublisherPageClient publisherSlug={params.publisherSlug} />;
76+
return (
77+
<PublisherPageClient
78+
publisherSlug={extractPublisherId(params.publisherSlug)}
79+
/>
80+
);
6281
}

0 commit comments

Comments
 (0)