Improve schema and update tags
- Make constants in schema explicit - Enumerate tag-categories - More i18n utilities - Better anonymous user support without special field - Remove most tuples and unchecked type-casting
This commit is contained in:
parent
579e5879e1
commit
17ef8c652c
34 changed files with 223 additions and 221 deletions
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
import { type CollectionEntry, getEntry } from "astro:content";
|
||||
import { type CollectionEntry } from "astro:content";
|
||||
import { type Lang } from "../content/config";
|
||||
import { getUsernameForLang } from "../utils/get_username_for_lang";
|
||||
|
||||
|
|
@ -9,13 +9,10 @@ type Props = {
|
|||
};
|
||||
|
||||
let { user, lang } = Astro.props;
|
||||
if (user.data.isAnonymous) {
|
||||
user = await getEntry("users", "anonymous");
|
||||
}
|
||||
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];
|
||||
const preferredLink = user.data.links[user.data.preferredLink]!;
|
||||
if (typeof preferredLink === "string") {
|
||||
link = preferredLink;
|
||||
} else {
|
||||
|
|
@ -25,11 +22,11 @@ if (user.data.preferredLink) {
|
|||
---
|
||||
|
||||
{
|
||||
user.data.isAnonymous || !user.data.preferredLink ? (
|
||||
<span>{username}</span>
|
||||
) : (
|
||||
link ? (
|
||||
<a href={link} class="text-link underline" target="_blank">
|
||||
{username}
|
||||
</a>
|
||||
) : (
|
||||
<span>{username}</span>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue