11import { useTranslations } from 'next-intl'
2-
3- export interface resourceUrls {
4- download ?: string
5- changelog ?: string
6- pricing ?: string
7- blog ?: string
8- mcp ?: string
9- issue ?: string
10- }
11-
12- export interface CommunityUrls {
13- linkedin ?: string
14- twitter ?: string
15- github ?: string
16- youtube ?: string
17- discord ?: string
18- reddit ?: string
19- blog ?: string
20- }
2+ import type { ManifestCommunityUrls , ManifestResourceUrls } from '@/types/manifests'
213
224export interface ProductLinksProps {
23- resourceUrls ?: resourceUrls
24- communityUrls ?: CommunityUrls
5+ resourceUrls ?: ManifestResourceUrls | null
6+ communityUrls ?: ManifestCommunityUrls | null
257}
268
279export function ProductLinks ( { resourceUrls, communityUrls } : ProductLinksProps ) {
2810 const t = useTranslations ( 'components.productLinks' )
2911
12+ // Normalize manifest URLs to component-friendly optional strings
13+ const normalizedResourceUrls : Record < string , string | undefined > = {
14+ download : resourceUrls ?. download ?? undefined ,
15+ changelog : resourceUrls ?. changelog ?? undefined ,
16+ pricing : resourceUrls ?. pricing ?? undefined ,
17+ mcp : resourceUrls ?. mcp ?? undefined ,
18+ issue : resourceUrls ?. issue ?? undefined ,
19+ blog : undefined ,
20+ }
21+
22+ const normalizedCommunityUrls = {
23+ linkedin : communityUrls ?. linkedin ?? undefined ,
24+ twitter : communityUrls ?. twitter ?? undefined ,
25+ github : communityUrls ?. github ?? undefined ,
26+ youtube : communityUrls ?. youtube ?? undefined ,
27+ discord : communityUrls ?. discord ?? undefined ,
28+ reddit : communityUrls ?. reddit ?? undefined ,
29+ blog : communityUrls ?. blog ?? undefined ,
30+ }
31+
3032 // Check if there's any content to display
31- const hasresourceUrls = resourceUrls && Object . values ( resourceUrls ) . some ( url => url )
32- const hasCommunityUrls = communityUrls && Object . values ( communityUrls ) . some ( url => url )
33+ const hasresourceUrls = Object . values ( normalizedResourceUrls ) . some ( url => url )
34+ const hasCommunityUrls = Object . values ( normalizedCommunityUrls ) . some ( url => url )
3335
3436 // If both resourceUrls and communityUrls have no values, don't render the component
3537 if ( ! hasresourceUrls && ! hasCommunityUrls ) {
@@ -53,14 +55,14 @@ export function ProductLinks({ resourceUrls, communityUrls }: ProductLinksProps)
5355 // Generate link configurations for resourceUrls by iterating over keys
5456 const pageUrlLinks = pageUrlKeys . map ( key => ( {
5557 key,
56- url : resourceUrls ?. [ key ] ,
58+ url : normalizedResourceUrls [ key ] ,
5759 label : t ( key ) ,
5860 } ) )
5961
6062 // Generate link configurations for communityUrls by iterating over keys
6163 const communityUrlLinks = communityUrlKeys . map ( key => ( {
6264 key,
63- url : communityUrls ?. [ key ] ,
65+ url : normalizedCommunityUrls [ key ] ,
6466 label : t ( key ) ,
6567 } ) )
6668
0 commit comments