feat: resolve status paths with router (#258)
This commit is contained in:
parent
24bbe9135b
commit
4ed1816806
22 changed files with 106 additions and 50 deletions
|
@ -2,6 +2,7 @@
|
|||
import { parseURL } from 'ufo'
|
||||
|
||||
definePageMeta({
|
||||
name: 'permalink',
|
||||
middleware: async (to) => {
|
||||
const HANDLED_MASTO_URL = /^(https?:\/\/)?(\w+\.)+\w+\/(@[@\w\d\.]+)(\/\d+)?$/
|
||||
try {
|
||||
|
@ -24,16 +25,11 @@ definePageMeta({
|
|||
const { value } = await useMasto().search({ q: permalink, resolve: true, limit: 1 }).next()
|
||||
|
||||
const { accounts, statuses } = value
|
||||
if (statuses[0]) {
|
||||
return {
|
||||
path: getStatusPath(statuses[0]),
|
||||
state: {
|
||||
status: statuses[0] as any,
|
||||
},
|
||||
}
|
||||
}
|
||||
if (statuses[0])
|
||||
return getStatusRoute(statuses[0])
|
||||
|
||||
if (accounts[0])
|
||||
return getAccountPath(accounts[0])
|
||||
return getAccountRoute(accounts[0])
|
||||
}
|
||||
catch {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue