feat: resolve status paths with router (#258)

This commit is contained in:
Daniel Roe 2022-11-30 17:15:18 +00:00 committed by GitHub
parent 24bbe9135b
commit 4ed1816806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 106 additions and 50 deletions

View file

@ -9,7 +9,7 @@ const { account, link = true } = defineProps<{
<template>
<NuxtLink
:to="link ? getAccountPath(account) : undefined"
:to="link ? getAccountRoute(account) : undefined"
flex="~ col" min-w-0 md:flex="~ row gap-2" md:items-center
text-link-rounded
>

View file

@ -77,7 +77,7 @@ const toggleTranslation = async () => {
}
const copyLink = async (status: Status) => {
const url = getStatusPermalink(status)
const url = getStatusPermalinkRoute(status)
if (url)
await clipboard.copy(`${location.origin}${url}`)
}

View file

@ -30,13 +30,13 @@ function onclick(evt: MouseEvent | KeyboardEvent) {
}
function go(evt: MouseEvent | KeyboardEvent) {
const path = getStatusPath(status)
const route = getStatusRoute(status)
if (evt.metaKey || evt.ctrlKey) {
window.open(path)
window.open(route.href)
}
else {
cacheStatus(status)
router.push(path)
router.push(route)
}
}
@ -57,7 +57,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
<div flex gap-4>
<div>
<AccountHoverWrapper :account="status.account">
<NuxtLink :to="getAccountPath(status.account)" rounded-full>
<NuxtLink :to="getAccountRoute(status.account)" rounded-full>
<AccountAvatar w-12 h-12 :account="status.account" />
</NuxtLink>
</AccountHoverWrapper>
@ -70,7 +70,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
<div flex-auto />
<div text-sm text-secondary flex="~ row nowrap" hover:underline>
<CommonTooltip :content="createdAt">
<a :title="status.createdAt" :href="getStatusPath(status)" @click.prevent="go($event)">
<a :title="status.createdAt" :href="getStatusRoute(status).href" @click.prevent="go($event)">
<time text-sm hover:underline :datetime="status.createdAt">
{{ timeago }}
</time>

View file

@ -19,7 +19,7 @@ const visibility = $computed(() => STATUS_VISIBILITIES.find(v => v.value === sta
<template>
<div :id="`status-${status.id}`" flex flex-col gap-2 py3 px-4>
<NuxtLink :to="getAccountPath(status.account)" rounded-full hover:bg-active transition-100 pr5 mr-a>
<NuxtLink :to="getAccountRoute(status.account)" rounded-full hover:bg-active transition-100 pr5 mr-a>
<AccountHoverWrapper :account="status.account">
<AccountInfo :account="status.account" />
</AccountHoverWrapper>

View file

@ -12,7 +12,7 @@ const account = useAccountById(status.inReplyToAccountId!)
<NuxtLink
v-if="status.inReplyToId"
flex="~ wrap" items-center text-sm text-secondary
:to="getStatusInReplyToPath(status)"
:to="getStatusInReplyToRoute(status)"
:title="account ? `Replying to ${getDisplayName(account)}` : 'Replying to someone'"
>
<div i-ri:reply-fill rotate-180 text-secondary-light class="mr-1.5" />