Skip to content

Commit 263c98a

Browse files
ericyangpanclaude
andcommitted
feat(types): add shared LocalePageProps type and improve manifest type alignment
Add LocalePageProps type for consistent locale param handling across pages. Update ProductLinks to use manifest types directly for better type safety. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 88f217a commit 263c98a

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

src/components/product/ProductLinks.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
import { 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

224
export interface ProductLinksProps {
23-
resourceUrls?: resourceUrls
24-
communityUrls?: CommunityUrls
5+
resourceUrls?: ManifestResourceUrls | null
6+
communityUrls?: ManifestCommunityUrls | null
257
}
268

279
export 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

src/types/locale.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Shared types for Next.js route params that include locale.
3+
*/
4+
export type LocaleParams = Promise<{ locale: string }>
5+
6+
export type LocalePageProps = {
7+
/**
8+
* Route params containing the locale.
9+
*/
10+
params: LocaleParams
11+
}

0 commit comments

Comments
 (0)