Add static checking to i18n and improve types

This commit is contained in:
Bad Manners 2024-07-24 21:48:46 -03:00
parent f8ac450ab5
commit 579e5879e1
16 changed files with 126 additions and 82 deletions

View file

@ -140,7 +140,6 @@ const { instance, user, postId } = Astro.props;
throw new Error(`Received error status ${response.status} - ${response.statusText}!`);
}
const data: { ancestors: Comment[]; descendants: Comment[] } = await response.json();
// console.log(data);
const commentsList: HTMLElement[] = [];
const commentMap: Record<string, number> = {};

View file

@ -1,7 +1,7 @@
---
import { type CollectionEntry, getEntry } from "astro:content";
import { t } from "../i18n";
import { type Lang } from "../content/config";
import { getUsernameForLang } from "../utils/get_username_for_lang";
type Props = {
lang: Lang;
@ -12,7 +12,7 @@ let { user, lang } = Astro.props;
if (user.data.isAnonymous) {
user = await getEntry("users", "anonymous");
}
const username = t(lang, user.data.nameLang as any) || user.data.name;
const username = getUsernameForLang(user, lang);
let link: string | null = null;
if (user.data.preferredLink) {
const preferredLink = user.data.links[user.data.preferredLink] as string | [string, string];