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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { groq } from '#imports'
const locationQuery = groq`*[_type == 'location'] | order(_updatedAt desc)[0] { city, region, country, countryCode, meetupAvailable, _updatedAt}`
interface Location { city: string region?: string country: string countryCode: string meetupAvailable: boolean _updatedAt: string}
export default defineEventHandler(async event => { const sanity = useSanity(event)
const location = await sanity.client.fetch<Location>(locationQuery)
if (!location) { return null }
// Convert country code to flag emoji const flagEmoji = location.region === 'Scotland' ? '🏴' : location.countryCode ? String.fromCodePoint(...[...location.countryCode.toUpperCase()].map(char => char.charCodeAt(0) + 127397)) : '🌍'
const locationMaps: Record<string, string | undefined> = { 'United Kingdom of Great Britain and Northern Ireland (the)': location.region, 'United States of America (the)': location.region, 'Netherlands (Kingdom of the)': 'The Netherlands', }
return { meetupAvailable: location.meetupAvailable, city: locationMaps[location.city] || location.city, area: location.region === 'Scotland' ? 'Scotland' : locationMaps[location.country] || location.country, flagEmoji, }})