1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-09 18:39:58 +00:00
elk/composables/masto/routes.ts
renovate[bot] 3c43a1cdd1
chore(deps): update lint (#1928)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
2023-03-30 19:01:24 +00:00

76 lines
1.7 KiB
TypeScript

import { withoutProtocol } from 'ufo'
import type { mastodon } from 'masto'
export function getAccountRoute(account: mastodon.v1.Account) {
return useRouter().resolve({
name: 'account-index',
params: {
server: currentServer.value,
account: extractAccountHandle(account),
},
})
}
export function getAccountFollowingRoute(account: mastodon.v1.Account) {
return useRouter().resolve({
name: 'account-following',
params: {
server: currentServer.value,
account: extractAccountHandle(account),
},
})
}
export function getAccountFollowersRoute(account: mastodon.v1.Account) {
return useRouter().resolve({
name: 'account-followers',
params: {
server: currentServer.value,
account: extractAccountHandle(account),
},
})
}
export function getStatusRoute(status: mastodon.v1.Status) {
return useRouter().resolve({
name: 'status',
params: {
server: currentServer.value,
account: extractAccountHandle(status.account),
status: status.id,
},
})
}
export function getTagRoute(tag: string) {
return useRouter().resolve({
name: 'tag',
params: {
server: currentServer.value,
tag,
},
})
}
export function getStatusPermalinkRoute(status: mastodon.v1.Status) {
return status.url ? withoutProtocol(status.url) : null
}
export function getStatusInReplyToRoute(status: mastodon.v1.Status) {
return useRouter().resolve({
name: 'status-by-id',
params: {
server: currentServer.value,
status: status.inReplyToId,
},
})
}
export function navigateToStatus({ status, focusReply = false }: {
status: mastodon.v1.Status
focusReply?: boolean
}) {
return navigateTo({
path: getStatusRoute(status).href,
state: { focusReply },
})
}