PronounsPage/app/components/SimplePronounList.vue
Valentyne Stigloher 10180aa6a3 (refactor) use #shared alias instead of ~~/shared
the #shared alias used by Nuxt cannot be easily disabled and to prevent breackage with jiti, we make use of it
2025-08-17 18:56:02 +02:00

56 lines
1.9 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { buildPronounUsage } from '#shared/buildPronoun.ts';
import type { Pronoun } from '#shared/classes.ts';
import { loadPronounLibrary } from '~/src/data.ts';
const props = defineProps<{
pronouns: Pronoun[] | string[];
}>();
const { $translator: translator } = useNuxtApp();
const config = useConfig();
const pronounLibrary = await loadPronounLibrary(config);
const glue = ` ${translator.translate('pronouns.or')} `;
const visiblePronouns = computed(() => {
return props.pronouns
.map((pronoun) => {
if (typeof pronoun === 'string') {
const usage = buildPronounUsage(pronounLibrary, pronoun, config, translator);
if (usage) {
return {
path: pronoun,
short: usage.short.options.join(usage.short.glue),
};
}
} else if (!pronoun.hidden) {
return {
path: pronoun.canonicalName,
short: pronoun.name(glue),
description: pronoun.description,
normative: pronoun.normative,
smallForm: pronoun.smallForm ? pronoun.morphemes[pronoun.smallForm] : undefined,
};
}
})
.filter((entry) => entry !== undefined);
});
</script>
<template>
<ul>
<li v-for="pronoun in visiblePronouns" :key="pronoun.path">
<PronounsIndexLink :path="pronoun.path">
<strong><Spelling :text="pronoun.short" /></strong><small v-if="pronoun.smallForm">/<Spelling :text="pronoun.smallForm" /></small>
<template v-if="pronoun.description">
<small><Spelling :text="pronoun.description as string" /></small>
</template>
</PronounsIndexLink>
<NormativeBadge v-if="pronoun.normative" />
</li>
</ul>
</template>