(pl)(bug)(pronouns) fix avoiding throwing 500

This commit is contained in:
Andrea Vos 2025-01-21 17:58:55 +01:00
parent 96cd191bff
commit c35a338642

View File

@ -4,14 +4,25 @@ import { SourceLibrary } from '../src/classes.ts';
const config = useConfig();
const { data: sources } = useAsyncData(async () => {
if (!config.pronouns.enabled || !config.pronouns.null || !config.pronouns.null.routes) {
const key = config.pronouns.enabled && config.pronouns.null && config.pronouns.null.routes
? config.pronouns.null.routes[0]
: null;
const { data: sourcesRaw } = useAsyncData(async () => {
if (!key) {
return;
}
const key = config.pronouns.null.routes[0];
const sourcesRaw = await $fetch(`/api/sources?pronoun=${key}`);
return await $fetch(`/api/sources?pronoun=${key}`);
});
const sources = computed(() => {
if (!key) {
return;
}
return {
'': new SourceLibrary(config, sourcesRaw).getForPronoun(key),
'': new SourceLibrary(config, sourcesRaw.value).getForPronoun(key),
};
});
</script>