refactor: tidy composables
This commit is contained in:
parent
bf8070c4b9
commit
e0741d58a9
14 changed files with 177 additions and 175 deletions
65
composables/masto/routes.ts
Normal file
65
composables/masto/routes.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import { withoutProtocol } from 'ufo'
|
||||
import type { Account, Status } from 'masto'
|
||||
|
||||
export function getAccountRoute(account: Account) {
|
||||
return useRouter().resolve({
|
||||
name: 'account-index',
|
||||
params: {
|
||||
server: currentServer.value,
|
||||
account: extractAccountHandle(account),
|
||||
},
|
||||
})
|
||||
}
|
||||
export function getAccountFollowingRoute(account: Account) {
|
||||
return useRouter().resolve({
|
||||
name: 'account-following',
|
||||
params: {
|
||||
server: currentServer.value,
|
||||
account: extractAccountHandle(account),
|
||||
},
|
||||
})
|
||||
}
|
||||
export function getAccountFollowersRoute(account: Account) {
|
||||
return useRouter().resolve({
|
||||
name: 'account-followers',
|
||||
params: {
|
||||
server: currentServer.value,
|
||||
account: extractAccountHandle(account),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function getStatusRoute(status: 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: Status) {
|
||||
return status.url ? withoutProtocol(status.url) : null
|
||||
}
|
||||
|
||||
export function getStatusInReplyToRoute(status: Status) {
|
||||
return useRouter().resolve({
|
||||
name: 'status-by-id',
|
||||
params: {
|
||||
server: currentServer.value,
|
||||
status: status.inReplyToId,
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue