mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 21:46:22 -04:00

the #shared alias used by Nuxt cannot be easily disabled and to prevent breackage with jiti, we make use of it
22 lines
849 B
TypeScript
22 lines
849 B
TypeScript
import { buildPronounUsage } from '#shared/buildPronoun.ts';
|
|
import { getLocale, loadConfig, loadPronounLibrary, loadTranslator } from '~~/server/data.ts';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const locale = getLocale(event);
|
|
const [config, translator, pronounLibrary] =
|
|
await Promise.all([loadConfig(locale), loadTranslator(locale), loadPronounLibrary(locale)]);
|
|
checkIsConfigEnabledOr404(config, 'pronouns');
|
|
|
|
const path = getRouterParam(event, 'pronoun')!.split('/')
|
|
.map((p) => decodeURIComponent(p))
|
|
.join('/');
|
|
const usage = buildPronounUsage(pronounLibrary, path, config, translator);
|
|
if (usage === null) {
|
|
throw createError({
|
|
status: 404,
|
|
statusMessage: 'Not Found',
|
|
});
|
|
}
|
|
return usage.short.options.join(usage.short.glue);
|
|
});
|