elk/plugins/masto.ts

14 lines
354 B
TypeScript
Raw Normal View History

2022-11-14 02:20:07 +00:00
import { login } from 'masto'
2022-11-14 14:54:30 +00:00
export const DEFAULT_SERVER = 'https://mas.to'
2022-11-14 02:20:07 +00:00
export default defineNuxtPlugin((nuxt) => {
2022-11-14 14:54:30 +00:00
const server = useCookie('nuxtodon-server')
const token = useCookie('nuxtodon-token')
2022-11-14 02:20:07 +00:00
const masto = login({
2022-11-14 14:54:30 +00:00
url: server.value || DEFAULT_SERVER,
accessToken: token.value,
2022-11-14 02:20:07 +00:00
})
nuxt.vueApp.provide('masto', masto)
})