<script setup lang="ts">
const config = useContentConfig()
const {preferLocale} = useContentPreference()
const {locale, path} = useContentInjected()

const locales = config.locale?.list ?? []
const candidates = computed(() => locales.filter(l => l.code !== locale.value))
</script>

<template>
  <NuxtLink
    v-for="candidate in candidates"
    :key="candidate.code"
    :to="{ path: path(undefined, {locale: candidate.code}).value, query: { freeze: 'true' }}"
    @click="preferLocale(candidate.code)">
    {{ candidate.code.toUpperCase() }}
  </NuxtLink>
</template>
