feat: always show account server (#119)
This commit is contained in:
parent
de468fb28b
commit
1194d56d09
16
components/account/AccountHandle.vue
Normal file
16
components/account/AccountHandle.vue
Normal file
@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import type { Account } from 'masto'
|
||||
|
||||
const { account } = defineProps<{
|
||||
account: Account
|
||||
}>()
|
||||
|
||||
const serverName = $computed(() => getServerName(account))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p>
|
||||
<span>{{ getShortHandle(account) }}</span>
|
||||
<span v-if="serverName" text="gray/95">@{{ serverName }}</span>
|
||||
</p>
|
||||
</template>
|
@ -66,9 +66,7 @@ function previewAvatar() {
|
||||
</button>
|
||||
<div flex flex-col>
|
||||
<ContentRich font-bold text-2xl break-words :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<p op50>
|
||||
{{ getShortHandle(account) }}
|
||||
</p>
|
||||
<AccountHandle :account="account" op50 />
|
||||
</div>
|
||||
</div>
|
||||
<div flex gap-2 items-center>
|
||||
@ -94,13 +92,13 @@ function previewAvatar() {
|
||||
</div>
|
||||
</div>
|
||||
<div flex gap-5>
|
||||
<NuxtLink :to="`/${getFullHandle(account)}/`" exact-active-class="text-primary">
|
||||
<NuxtLink :to="getAccountPath(account)" exact-active-class="text-primary">
|
||||
<span font-bold>{{ formattedNumber(account.statusesCount) }}</span> <span op50>Posts</span>
|
||||
</NuxtLink>
|
||||
<NuxtLink :to="`/${getFullHandle(account)}/following`" exact-active-class="text-primary">
|
||||
<NuxtLink :to="`${getAccountPath(account)}/following`" exact-active-class="text-primary">
|
||||
<span font-bold>{{ humanReadableNumber(account.followingCount) }}</span> <span op50>Following</span>
|
||||
</NuxtLink>
|
||||
<NuxtLink :to="`/${getFullHandle(account)}/followers`" exact-active-class="text-primary">
|
||||
<NuxtLink :to="`${getAccountPath(account)}/followers`" exact-active-class="text-primary">
|
||||
<span font-bold>{{ humanReadableNumber(account.followersCount) }}</span> <span op50>Followers</span>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
@ -20,9 +20,7 @@ const accountHandle = $(useAccountHandle(account, fullServer))
|
||||
</div>
|
||||
<NuxtLink flex flex-col :to="link ? getAccountPath(account) : null">
|
||||
<ContentRich font-bold hover:underline :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<p op35 text-sm>
|
||||
{{ accountHandle }}
|
||||
</p>
|
||||
<AccountHandle :account="account" text-sm op35 />
|
||||
<slot name="bottom" />
|
||||
</NuxtLink>
|
||||
<slot />
|
||||
|
@ -35,6 +35,10 @@ export const STATUS_VISIBILITIES = [
|
||||
},
|
||||
] as const
|
||||
|
||||
export function getServerName(account: Account) {
|
||||
return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || ''
|
||||
}
|
||||
|
||||
export function getDisplayName(account: Account) {
|
||||
return account.displayName || account.username
|
||||
}
|
||||
@ -47,7 +51,7 @@ export function getFullHandle(account: Account) {
|
||||
const handle = `@${account.acct}`
|
||||
if (!currentUser.value || account.acct.includes('@'))
|
||||
return handle
|
||||
return `${handle}@${account.url.match(UserLinkRE)?.[1] || currentUser.value.server}`
|
||||
return `${handle}@${getServerName(account)}`
|
||||
}
|
||||
|
||||
export function toShortHandle(fullHandle: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user