14 lines
357 B
TypeScript
14 lines
357 B
TypeScript
|
|
import { localizationKey } from "../../../i18nLanguages";
|
||
|
|
import type { Post } from "../../../types/post";
|
||
|
|
|
||
|
|
export function postDisplayText(post: Post, lang: string): string {
|
||
|
|
const key = localizationKey(lang);
|
||
|
|
return (
|
||
|
|
post.localizations?.[
|
||
|
|
key as keyof typeof post.localizations
|
||
|
|
]?.text?.trim() ||
|
||
|
|
post.text?.trim() ||
|
||
|
|
""
|
||
|
|
);
|
||
|
|
}
|