diff --git a/components/team-flag.tsx b/components/team-flag.tsx
index 8ea2f0b..541d4a2 100644
--- a/components/team-flag.tsx
+++ b/components/team-flag.tsx
@@ -9,8 +9,42 @@ interface Props {
const sizes = { sm: 'text-lg', md: 'text-2xl', lg: 'text-4xl', xl: 'text-[60px]' }
+const placeholderSize = {
+ sm: { width: '1.35em', height: '1em', fontSize: '0.38em' },
+ md: { width: '1.35em', height: '1em', fontSize: '0.38em' },
+ lg: { width: '1.35em', height: '1em', fontSize: '0.38em' },
+ xl: { width: '1.35em', height: '1em', fontSize: '0.38em' },
+}
+
export function TeamFlag({ name, iso2, size = 'md', className = '' }: Props) {
- const code = iso2 ?? getIso(name)
+ const code = iso2 !== undefined ? iso2 : getIso(name)
+
+ if (!code) {
+ const abbr = name
+ .split(/\s+/)
+ .map(w => w[0])
+ .join('')
+ .slice(0, 3)
+ .toUpperCase()
+ return (
+
+ {abbr}
+
+ )
+ }
+
return (
= {
+export const TEAM_ISO: Record = {
// A
'Afghanistan': 'af', 'Albania': 'al', 'Algeria': 'dz', 'Angola': 'ao',
'Argentina': 'ar', 'Armenia': 'am', 'Australia': 'au', 'Austria': 'at',
@@ -19,7 +19,8 @@ export const TEAM_ISO: Record = {
// F
'Finland': 'fi', 'France': 'fr',
// G
- 'Gabon': 'ga', 'Germany': 'de', 'West Germany': 'de', 'East Germany': 'de',
+ 'Gabon': 'ga', 'Germany': 'de', 'West Germany': 'de',
+ 'East Germany': null, 'Germany DR': null,
'Ghana': 'gh', 'Greece': 'gr', 'Guatemala': 'gt', 'Guinea': 'gn',
// H
'Haiti': 'ht', 'Honduras': 'hn', 'Hungary': 'hu',
@@ -48,10 +49,11 @@ export const TEAM_ISO: Record = {
// Q
'Qatar': 'qa',
// R
- 'Romania': 'ro', 'Russia': 'ru', 'Soviet Union': 'su',
+ 'Romania': 'ro', 'Russia': 'ru', 'Soviet Union': null,
// S
'Saudi Arabia': 'sa', 'Scotland': 'gb-sct', 'Senegal': 'sn',
- 'Serbia': 'rs', 'Yugoslavia': 'yu', 'Slovakia': 'sk', 'Slovenia': 'si',
+ 'Serbia': 'rs', 'Yugoslavia': null, 'FR Yugoslavia': null, 'Czechoslovakia': null,
+ 'Slovakia': 'sk', 'Slovenia': 'si',
'Somalia': 'so', 'South Africa': 'za', 'South Korea': 'kr',
'Korea Republic': 'kr', 'Spain': 'es', 'Sweden': 'se', 'Switzerland': 'ch',
// T
@@ -68,8 +70,9 @@ export const TEAM_ISO: Record = {
'Zambia': 'zm', 'Zimbabwe': 'zw',
}
-export function getIso(teamName: string): string {
- return TEAM_ISO[teamName] ?? teamName.toLowerCase().replace(/\s+/g, '-').substring(0, 2)
+export function getIso(teamName: string): string | null {
+ if (teamName in TEAM_ISO) return TEAM_ISO[teamName]
+ return null
}
export function slugify(name: string): string {
diff --git a/scripts/sync.ts b/scripts/sync.ts
index e0b4f1f..51b1154 100644
--- a/scripts/sync.ts
+++ b/scripts/sync.ts
@@ -130,9 +130,9 @@ async function run() {
const teamCache = new Map()
- async function upsertTeam(rawName: string, extra?: { iso2?: string; fifaCode?: string; continent?: string; confederation?: string }) {
+ async function upsertTeam(rawName: string, extra?: { iso2?: string | null; fifaCode?: string; continent?: string; confederation?: string }) {
if (teamCache.has(rawName)) return teamCache.get(rawName)!
- const iso2 = extra?.iso2 ?? getIso(rawName)
+ const iso2 = (extra && 'iso2' in extra) ? extra.iso2 : getIso(rawName)
const [row] = await db.execute(sql`
INSERT INTO teams (name, iso2, fifa_code, continent, confederation)
VALUES (${rawName}, ${iso2 ?? null}, ${extra?.fifaCode ?? null}, ${extra?.continent ?? null}, ${extra?.confederation ?? null})