diff --git a/server/nouns.ts b/server/nouns.ts index 76c400675..c4aab42e5 100644 --- a/server/nouns.ts +++ b/server/nouns.ts @@ -32,6 +32,7 @@ type NounRowWithAuthor = NounRow & { author: User['username'] }; export const parseNounRow = (nounRow: NounRow): Omit => { return { id: nounRow.id, + key: nounRow.key, words: JSON.parse(nounRow.words), classInstance: nounRow.classInstance ? JSON.parse(nounRow.classInstance) : null, categories: nounRow.categories?.split('|') ?? [], diff --git a/src/classes.ts b/src/classes.ts index a462367a3..6c11f5a1b 100644 --- a/src/classes.ts +++ b/src/classes.ts @@ -844,6 +844,7 @@ export class PronounLibrary { export interface NounRaw { id: string; + key?: string | null; words: NounWordsRaw; classInstance?: NounClassInstance | null; categories?: string[]; @@ -921,6 +922,7 @@ const hasWordOfGender = (words: NounWords, gender: Gender): boolean => { export class Noun implements Entry { id: string; + key: string; words: NounWords; classInstance: NounClassInstance | null; categories: string[]; @@ -932,6 +934,7 @@ export class Noun implements Entry { constructor(config: Config, nounRaw: NounRawWithLoadedWords) { this.id = nounRaw.id; + this.key = nounRaw.key ?? ''; this.words = nounRaw.words; this.classInstance = nounRaw.classInstance ?? null; this.categories = nounRaw.categories ?? []; @@ -996,7 +999,7 @@ export class Noun implements Entry { if (!this.approved && other.approved) { return -1; } - return collator.compare(this.firstWords[0], other.firstWords[0]); + return collator.compare(this.key, other.key); } } @@ -1036,6 +1039,7 @@ export class NounTemplate { fill(stem: string): Omit { return { + key: stem, words: { masc: { singular: this.masc.map((e) => ({ spelling: e.replace('-', stem) })),