Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
at feat/nuxt-v5
12345678910111213141516171819202122232425262728293031323334import { defineEventHandler } from 'nuxt/server'
import { getCurrentLocation } from '../utils/cms/location'
const regionalFlags: Record<string, string> = { Scotland: '🏴',}
const countryNames = new Intl.DisplayNames(['en'], { type: 'region' })
export default defineEventHandler(async () => { const location = await getCurrentLocation() if (!location) return null
const countryCode = location.countryCode.toUpperCase()
const flagEmoji = (location.region && regionalFlags[location.region]) || (countryCode ? String.fromCodePoint(...[...countryCode].map(char => char.charCodeAt(0) + 127397)) : '🌍')
// The UK and the US are big enough that the subdivision is the more useful // label; elsewhere the country reads better. const area = (['GB', 'US'].includes(countryCode) && location.region) || (countryCode ? countryNames.of(countryCode) : undefined)
return { meetupAvailable: location.meetupAvailable, city: location.city, area: area ?? '', flagEmoji, }})