1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-15 05:19:58 +00:00
elk/plugins/masto.ts

23 lines
583 B
TypeScript
Raw Permalink Normal View History

2023-01-15 08:38:02 +00:00
export default defineNuxtPlugin(() => {
const { params, query } = useRoute()
2023-01-15 08:38:02 +00:00
publicServer.value = params.server as string || useRuntimeConfig().public.defaultServer
2023-01-15 08:38:02 +00:00
const masto = createMasto()
2023-03-19 12:12:20 +00:00
const user = (typeof query.server === 'string' && typeof query.token === 'string')
2023-01-15 08:38:02 +00:00
? {
server: query.server,
token: query.token,
vapidKey: typeof query.vapid_key === 'string' ? query.vapid_key : undefined,
}
2023-03-19 12:12:20 +00:00
: (currentUser.value || { server: publicServer.value })
2022-11-26 19:33:36 +00:00
2023-01-15 08:38:02 +00:00
loginTo(masto, user)
return {
provide: {
masto,
},
}
})