diff --git a/components/nouns/NounsConventionPage.vue b/components/nouns/NounsConventionPage.vue index 25a117338..dac71df50 100644 --- a/components/nouns/NounsConventionPage.vue +++ b/components/nouns/NounsConventionPage.vue @@ -6,7 +6,7 @@ import { MorphemeValues } from '~/src/language/morphemes.ts'; import type { NounConvention } from '~/src/nouns.ts'; const props = defineProps<{ - nounConvention: NounConvention; + nounConvention: WithKey; }>(); const { $translator: translator } = useNuxtApp(); @@ -39,6 +39,12 @@ const examples = computed(() => { return nounConventions?.examples.map((example) => Example.parse(example)) .filter((example) => example.areRequiredExampleValuesPresent(exampleValues.value!)); }); + +const nounConventionGroup = computed(() => { + return Object.values(nounConventions.groups).find((nounConventionGroup) => { + return nounConventionGroup.conventions.includes(props.nounConvention.key); + }); +}); diff --git a/middleware/languageItemFromPath.ts b/middleware/languageItemFromPath.ts index 771b227e2..5ba1d2c03 100644 --- a/middleware/languageItemFromPath.ts +++ b/middleware/languageItemFromPath.ts @@ -25,11 +25,8 @@ const findNounConvention = async (path: string, config: Config) => { const nounConventions = await loadNounConventions(); - for (const [key, nounConvention] of Object.entries(nounConventions?.conventions ?? {})) { - if (key === path) { - return nounConvention; - } - } + return withKey(nounConventions?.conventions ?? {}) + .find((nounConvention) => nounConvention.key === path); }; export default defineNuxtRouteMiddleware(async (to) => { diff --git a/nuxt.config.ts b/nuxt.config.ts index 8d8115809..907bef84f 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -37,7 +37,7 @@ declare module 'vue-router' { interface RouteMeta { headerCategory?: string; pronoun?: Pronoun; - nounConvention?: NounConvention; + nounConvention?: WithKey; } }