Add description exports and collapse characters from same user
This commit is contained in:
parent
2990644f87
commit
d4a9dc9dbc
78 changed files with 693 additions and 247 deletions
|
|
@ -1,21 +1,35 @@
|
|||
---
|
||||
import { type User } from "../content/config";
|
||||
import { type CollectionEntry } from "astro:content";
|
||||
import { type Lang } from "../content/config";
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
lang: Lang;
|
||||
user: CollectionEntry<"users">;
|
||||
};
|
||||
|
||||
const { user } = Astro.props;
|
||||
const { user, lang } = Astro.props;
|
||||
const username = user.data.nameLang[lang] || user.data.name;
|
||||
let link: string | null = null;
|
||||
if (user.data.preferredLink) {
|
||||
if (user.data.preferredLink in user.data.links) {
|
||||
const preferredLink = user.data.links[user.data.preferredLink] as string | [string, string];
|
||||
if (typeof preferredLink === "string") {
|
||||
link = preferredLink;
|
||||
} else {
|
||||
link = preferredLink[0];
|
||||
}
|
||||
} else {
|
||||
throw new Error(`No preferredLink "${user.data.preferredLink}" for user ${user.id}`);
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
{
|
||||
typeof user === "string" ? (
|
||||
<span>{user}</span>
|
||||
user.data.preferredLink == null ? (
|
||||
<span>{username}</span>
|
||||
) : (
|
||||
Object.entries(user).map(([k, v]) => (
|
||||
<a href={v} class="text-link underline" target="_blank">
|
||||
<span>{k}</span>
|
||||
</a>
|
||||
))[0]
|
||||
<a href={link} class="text-link underline" target="_blank">
|
||||
{username}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue