mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
(refactor) rename and move entriesWithKeys and getWithKey utilities to ~~/shared/utils
This commit is contained in:
parent
9425d88df1
commit
9142a99b22
@ -16,7 +16,7 @@ const config = useConfig();
|
|||||||
const nounsData = await loadNounsData();
|
const nounsData = await loadNounsData();
|
||||||
|
|
||||||
const nouns = computed((): Noun[] => {
|
const nouns = computed((): Noun[] => {
|
||||||
return withKey(nounsData.classes ?? {})
|
return entriesWithKeys(nounsData.classes ?? {})
|
||||||
.map((nounClass): NounClassInstance => ({ classKey: nounClass.key, stems: props.stemValues }))
|
.map((nounClass): NounClassInstance => ({ classKey: nounClass.key, stems: props.stemValues }))
|
||||||
.map((classInstance, i): NounRawWithLoadedWords => ({
|
.map((classInstance, i): NounRawWithLoadedWords => ({
|
||||||
id: `template-${i}`,
|
id: `template-${i}`,
|
||||||
|
@ -7,7 +7,7 @@ const nounsData = await loadNounsData();
|
|||||||
<template>
|
<template>
|
||||||
<ul v-if="nounsData.groups" class="list-group mt-4">
|
<ul v-if="nounsData.groups" class="list-group mt-4">
|
||||||
<li
|
<li
|
||||||
v-for="nounConventionGroup of withKey(nounsData.groups)"
|
v-for="nounConventionGroup of entriesWithKeys(nounsData.groups)"
|
||||||
:key="nounConventionGroup.key"
|
:key="nounConventionGroup.key"
|
||||||
class="list-group-item"
|
class="list-group-item"
|
||||||
>
|
>
|
||||||
|
@ -11,7 +11,7 @@ if (nounsData === undefined) {
|
|||||||
throw new Error('nounsData is undefined');
|
throw new Error('nounsData is undefined');
|
||||||
}
|
}
|
||||||
const visibleNounConventions = computed(() => {
|
const visibleNounConventions = computed(() => {
|
||||||
return withKey(nounsData.conventions ?? {}).filter((nounConvention) => {
|
return entriesWithKeys(nounsData.conventions ?? {}).filter((nounConvention) => {
|
||||||
return props.nounConventionGroup.conventions.includes(nounConvention.key);
|
return props.nounConventionGroup.conventions.includes(nounConvention.key);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,7 @@ const id = useId();
|
|||||||
<template>
|
<template>
|
||||||
<h5><T>nouns.submit.regular.stems.header</T></h5>
|
<h5><T>nouns.submit.regular.stems.header</T></h5>
|
||||||
<p><T>nouns.submit.regular.stems.description</T></p>
|
<p><T>nouns.submit.regular.stems.description</T></p>
|
||||||
<template v-for="stem of withKey(nounsData.stems ?? {})" :key="stem.key">
|
<template v-for="stem of entriesWithKeys(nounsData.stems ?? {})" :key="stem.key">
|
||||||
<label :for="`${id}-stem-${stem.key}`">{{ stem.name }}</label>
|
<label :for="`${id}-stem-${stem.key}`">{{ stem.name }}</label>
|
||||||
<input
|
<input
|
||||||
:id="`${id}-stem-${stem.key}`"
|
:id="`${id}-stem-${stem.key}`"
|
||||||
|
@ -25,7 +25,7 @@ const findNounConvention = async (path: string, config: Config) => {
|
|||||||
|
|
||||||
const nounsData = await loadNounsData();
|
const nounsData = await loadNounsData();
|
||||||
|
|
||||||
return withKey(nounsData.conventions ?? {})
|
return entriesWithKeys(nounsData.conventions ?? {})
|
||||||
.find((nounConvention) => nounConvention.key === path);
|
.find((nounConvention) => nounConvention.key === path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import type {
|
|||||||
Gender,
|
Gender,
|
||||||
Numerus,
|
Numerus,
|
||||||
} from '~~/shared/nouns.ts';
|
} from '~~/shared/nouns.ts';
|
||||||
|
import type { WithKey } from '~~/shared/utils/entriesWithKeys.ts';
|
||||||
|
|
||||||
export class PronounExample {
|
export class PronounExample {
|
||||||
singular: Example;
|
singular: Example;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { WithKey } from '~/utils/withKey.ts';
|
import type { WithKey } from '~~/shared/utils/entriesWithKeys.ts';
|
||||||
|
|
||||||
export default <T>(record: Record<string, T> | undefined, key: string | undefined): WithKey<T> | undefined => {
|
export default <T>(record: Record<string, T> | undefined, key: string | undefined): WithKey<T> | undefined => {
|
||||||
if (key === undefined || record?.[key] === undefined) {
|
if (key === undefined || record?.[key] === undefined) {
|
Loading…
x
Reference in New Issue
Block a user