## Summary
- Fixed translation key format compatibility with next-intl
- Fixed pluralization format from i18next to next-intl format
- Fixed dynamic translation key error handling
- Updated server components to match API response structure
- Fixed useSearchParams import location
## Changes
- Changed pluralization from `{{count}} items` to `{count} items` format
- Added proper error handling for missing translation keys
- Fixed import paths for next-intl hooks
- Fixed PartyPageClient trying to set non-existent appState.parties
## Test plan
- [x] Verified translations render correctly
- [x] Tested pluralization works with different counts
- [x] Confirmed no console errors about missing translations
- [x] Tested party page functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
'use client'
|
|
|
|
import React from 'react'
|
|
import Head from 'next/head'
|
|
import { getCookie } from 'cookies-next'
|
|
import { useTranslations } from 'next-intl'
|
|
import api from '~utils/api'
|
|
|
|
import generateTitle from '~utils/generateTitle'
|
|
|
|
interface Props {
|
|
party: Party
|
|
meta: { [key: string]: string }
|
|
}
|
|
|
|
const PartyHead = ({ party, meta }: Props) => {
|
|
// Import translations
|
|
const t = useTranslations('common')
|
|
|
|
// Get locale from cookie
|
|
const cookieLocale = getCookie('NEXT_LOCALE') as string
|
|
const locale =
|
|
cookieLocale && ['en', 'ja'].includes(cookieLocale) ? cookieLocale : 'en'
|
|
const previewUrl = `${
|
|
process.env.NEXT_PUBLIC_SITE_URL || 'https://granblue.team'
|
|
}/p/${party.shortcode}/preview`
|
|
|
|
return (
|
|
<Head>
|
|
{/* HTML */}
|
|
<title>
|
|
{generateTitle(meta.element, party.user?.username, party.name)}
|
|
</title>
|
|
<meta
|
|
name="description"
|
|
content={t('page.descriptions.team', {
|
|
username: party.user?.username,
|
|
raidName: party.raid ? party.raid.name[locale] : '',
|
|
})}
|
|
/>
|
|
|
|
<link rel="icon" type="image/x-icon" href="/images/favicon.png" />
|
|
|
|
{/* OpenGraph */}
|
|
<meta
|
|
property="og:title"
|
|
content={generateTitle(meta.element, party.user?.username, party.name)}
|
|
/>
|
|
<meta
|
|
property="og:description"
|
|
content={t('page.descriptions.team', {
|
|
username: party.user?.username,
|
|
raidName: party.raid ? party.raid.name[locale] : '',
|
|
})}
|
|
/>
|
|
<meta
|
|
property="og:url"
|
|
content={`https://app.granblue.team/p/${party.shortcode}`}
|
|
/>
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:image" content={previewUrl} />
|
|
<meta property="og:image:width" content="1200" />
|
|
<meta property="og:image:height" content="630" />
|
|
|
|
{/* Twitter */}
|
|
<meta name="twitter:card" content="summary_large_image" />
|
|
<meta property="twitter:domain" content="app.granblue.team" />
|
|
<meta
|
|
name="twitter:title"
|
|
content={generateTitle(meta.element, party.user?.username, party.name)}
|
|
/>
|
|
<meta
|
|
name="twitter:description"
|
|
content={t('page.descriptions.team', {
|
|
username: party.user?.username,
|
|
raidName: party.raid ? party.raid.name[locale] : '',
|
|
})}
|
|
/>
|
|
<meta name="twitter:image" content={previewUrl} />
|
|
</Head>
|
|
)
|
|
}
|
|
|
|
export default PartyHead
|