mirror of
https://github.com/elk-zone/elk
synced 2024-11-23 22:56:09 +09:00
20 lines
455 B
TypeScript
20 lines
455 B
TypeScript
import { login } from 'masto'
|
|
|
|
export const DEFAULT_SERVER = 'mas.to'
|
|
|
|
export default defineNuxtPlugin((nuxt) => {
|
|
const server = useCookie('nuxtodon-server')
|
|
const token = useCookie('nuxtodon-token')
|
|
|
|
const masto = login({
|
|
url: `https://${server.value || DEFAULT_SERVER}`,
|
|
accessToken: token.value,
|
|
})
|
|
nuxt.vueApp.provide('masto', masto)
|
|
|
|
// Reload the page when the token changes
|
|
watch(token, () => {
|
|
location.reload()
|
|
})
|
|
})
|