Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use nuxt add component util for toaster #103

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
import {
defineNuxtModule,
addComponent,
addPlugin,
createResolver
} from '@nuxt/kit'

import type { NuxtModule } from '@nuxt/schema'

Expand All @@ -16,6 +21,12 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
setup(options: ModuleOptions, nuxt) {
const { resolve } = createResolver(import.meta.url)

addComponent({
name: 'Toaster',
export: 'Toaster',
filePath: 'vue-sonner'
})

addPlugin({
src: resolve('./runtime/plugin'),
mode: 'client'
Expand Down
8 changes: 2 additions & 6 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Toaster, toast } from 'vue-sonner'
import { toast } from 'vue-sonner'
import { defineNuxtPlugin } from 'nuxt/app'

import type { NuxtApp } from 'nuxt/app'

export default defineNuxtPlugin((nuxtApp: NuxtApp) => {
nuxtApp.vueApp.component('Toaster', Toaster)

export default defineNuxtPlugin(() => {
return {
provide: {
toast
Expand Down
Loading