23 lines
806 B
TypeScript

import { getLocale, loadConfig, loadPronouns } from '~/server/data.ts';
import { getPronounExamples, makePublicPronoun } from '~/server/pronouns.ts';
import type { PublicPronoun } from '~/server/pronouns.ts';
export default defineEventHandler(async (event) => {
const locale = getLocale(event);
const [config, pronouns, examples] = await Promise.all([
loadConfig(locale),
loadPronouns(locale),
getPronounExamples(event),
]);
checkIsConfigEnabledOr404(config, 'pronouns');
const publicPronouns: Record<string, PublicPronoun> = {};
for (const [name, pronoun] of Object.entries(pronouns)) {
if (pronoun.hidden) {
continue;
}
publicPronouns[name] = makePublicPronoun(pronoun, examples);
}
return publicPronouns;
});