|
|
--- |
|
|
interface Props { |
|
|
username: string; |
|
|
name?: string; |
|
|
url?: string; |
|
|
avatarUrl?: string; |
|
|
} |
|
|
|
|
|
const { username, name, url, avatarUrl } = Astro.props as Props; |
|
|
const profileUrl = url ?? `https://huggingface.co/${encodeURIComponent(username)}`; |
|
|
const displayName = name ?? username; |
|
|
const imgSrc = avatarUrl ?? `https://huggingface.co/api/users/${encodeURIComponent(username)}/avatar`; |
|
|
--- |
|
|
<div class="hf-user"> |
|
|
<div class="hf-user__left"> |
|
|
<img |
|
|
class="hf-user__avatar" |
|
|
src={imgSrc} |
|
|
alt={`${displayName} avatar`} |
|
|
width="44" |
|
|
height="44" |
|
|
loading="lazy" |
|
|
decoding="async" |
|
|
referrerpolicy="no-referrer" |
|
|
/> |
|
|
<span class="hf-user__text"> |
|
|
<a class="hf-user__name" href={profileUrl} target="_blank" rel="noopener noreferrer">{displayName}</a> |
|
|
<span class="hf-user__row"> |
|
|
<a class="hf-user__username" href={profileUrl} target="_blank" rel="noopener noreferrer">@{username}</a> |
|
|
</span> |
|
|
</span> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<style> |
|
|
.hf-user { |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
gap: 10px; |
|
|
padding: 10px 10px 10px 12px; |
|
|
border-radius: 12px; |
|
|
box-shadow: none; |
|
|
} |
|
|
.hf-user__left { |
|
|
display: flex; |
|
|
align-items: center; |
|
|
gap: 10px; |
|
|
text-decoration: none; |
|
|
color: inherit; |
|
|
} |
|
|
.hf-user__avatar { |
|
|
display: block; |
|
|
width: 44px; |
|
|
height: 44px; |
|
|
border-radius: 50%; |
|
|
object-fit: cover; |
|
|
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12) inset; |
|
|
} |
|
|
.hf-user__text { |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
line-height: 1.1; |
|
|
} |
|
|
.hf-user__row { |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
white-space: nowrap; |
|
|
} |
|
|
.hf-user__name { |
|
|
font-size: 14px; |
|
|
font-weight: 700; |
|
|
} |
|
|
.hf-user__username { |
|
|
font-size: 12px; |
|
|
color: var(--muted-color); |
|
|
text-decoration: underline!important; |
|
|
text-underline-offset: 2px; |
|
|
text-decoration-thickness: 0.06em; |
|
|
text-decoration-color: var(--link-underline); |
|
|
} |
|
|
|
|
|
.hf-user a { |
|
|
color: inherit; |
|
|
text-decoration: none; |
|
|
border-bottom: none; |
|
|
} |
|
|
</style> |
|
|
|
|
|
<style is:global> |
|
|
.hf-user-list { |
|
|
display: flex; |
|
|
flex-wrap: wrap; |
|
|
gap: 12px; |
|
|
} |
|
|
</style> |
|
|
|
|
|
|