diff --git a/app/app/src/components/CountryFlag.astro b/app/app/src/components/CountryFlag.astro new file mode 100644 index 0000000..214931d --- /dev/null +++ b/app/app/src/components/CountryFlag.astro @@ -0,0 +1,45 @@ +--- +type CountryCode = + | 'AUS' // Australia + | 'BEL' // Belgium + | 'CAN' // Canada + | 'CHE' // Switzerland + | 'ESP' // Spain + | 'FRA' // France + | 'GBR' // United Kingdom + | 'IDN' // Indonesia + | 'ITA' // Italy + | 'USA' // United States + +function parseCountryCode(code: any): string | undefined +{ + return typeof code === 'string' ? code.toUpperCase() : code +} + +const countryCode: CountryCode | undefined = parseCountryCode(Astro.props.country) as any +--- + +{ +countryCode === 'AUS' + ? +: countryCode === 'BEL' + ? +: countryCode === 'CAN' + ? +: countryCode === 'CHE' + ? +: countryCode === 'ESP' + ? +: countryCode === 'FRA' + ? +: countryCode === 'GBR' + ? +: countryCode === 'IDN' + ? +: countryCode === 'ITA' + ? +: countryCode === 'USA' + ? +: + {countryCode} +} diff --git a/app/app/src/components/SocialPlatformIcon.astro b/app/app/src/components/SocialPlatformIcon.astro new file mode 100644 index 0000000..a45b461 --- /dev/null +++ b/app/app/src/components/SocialPlatformIcon.astro @@ -0,0 +1,30 @@ +--- +type SocialPlatform = + | 'twitch' // Twitch + | 'twitter' // Twitter + | 'youtube' // YouTube + | 'tiktok' // TikTok + | 'instagram' // Instagram + +function parseSocialPlatform(code: any): string | undefined +{ + return typeof code === 'string' ? code.toLowerCase() : code +} + +const socialPlatform: SocialPlatform | undefined = parseSocialPlatform(Astro.props.platform) as any +--- + +{ +socialPlatform === 'twitch' + ? +: socialPlatform === 'twitter' + ? +: socialPlatform === 'youtube' + ? +: socialPlatform === 'tiktok' + ? +: socialPlatform === 'instagram' + ? +: + {socialPlatform} +} diff --git a/app/app/src/components/StreamersTable.astro b/app/app/src/components/StreamersTable.astro index 02d83d1..9b4015c 100644 --- a/app/app/src/components/StreamersTable.astro +++ b/app/app/src/components/StreamersTable.astro @@ -1,6 +1,8 @@ --- import YAML from 'yaml' +import CountryFlag from '~/components/CountryFlag.astro' +import SocialPlatformIcon from '~/components/SocialPlatformIcon.astro' import streamersSocialsYml from '~/data/streamers/socials.yml?raw' interface StreamerSocials { @@ -19,27 +21,6 @@ const streamersSocials = YAML.parse(streamersSocialsYml) as Record = streamersList.map( (name) => streamersSocials[name] || { name, country: '?', socials: [] } ) - -const countryFlag: Record = { - 'AUS': 'australia', - 'BEL': 'belgium', - 'CAN': 'canada', - 'CHE': 'switzerland', - 'ESP': 'spain', - 'FRA': 'france', - 'GBR': 'united-kingdom', - 'IDN': 'indonesia', - 'ITA': 'italy', - 'USA': 'united-states', -} - -const socialIcons: Record = { - 'twitch': 'mdi--twitch', - 'twitter': 'mdi--twitter', - 'youtube': 'mdi--youtube', - 'tiktok': 'ic--baseline-tiktok', - 'instagram': 'mdi--instagram', -} --- @@ -56,19 +37,14 @@ const socialIcons: Record = { {streamers.map((streamer) => (
- {countryFlag[streamer.country] !== undefined - ? - : {streamer.country} - } + {streamer.name} {streamer.socials?.map((social, index) => ( <> { - socialIcons[social.platform.toLowerCase()] !== undefined - ? - : {social.platform} + }{ }{index < streamer.socials.length - 1 && ', '} ))}