Skip to content

Commit

Permalink
feat: add support for Nuxt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
justintaddei committed Dec 5, 2023
1 parent 8ed51bd commit ee3ea2a
Show file tree
Hide file tree
Showing 9 changed files with 6,085 additions and 13,262 deletions.
File renamed without changes.
File renamed without changes.
35 changes: 24 additions & 11 deletions nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
const { resolve } = require('path')
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
import pkg from '../package.json'
import { isNuxt2 } from '@nuxt/kit'

module.exports = function nuxtVWave(moduleOptions) {
const options = Object.assign({}, this.options.vWave, moduleOptions)
export default defineNuxtModule({
meta: {
name: 'v-wave',
version: pkg.version,
configKey: 'vWave',
compatibility: {
nuxt: '^3.0.0 || ^2.16.0',
bridge: true
}
},
setup(options, nuxt) {
const { resolve } = createResolver(import.meta.url)

this.addPlugin({
ssr: false,
src: resolve(__dirname, 'plugin.js'),
fileName: 'v-wave-plugin.js',
options
})
}
if (isNuxt2()) {
nuxt.options.publicRuntimeConfig.vWave = options
} else {

module.exports.meta = require('../package.json')
nuxt.options.runtimeConfig.public.vWave = options
}

addPlugin(resolve('./plugin.js'))
}
})
24 changes: 22 additions & 2 deletions nuxt/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import Vue from 'vue'
import VWave from 'v-wave'
import { defineNuxtPlugin, useRuntimeConfig } from '#imports'

Vue.use(VWave, <%= serialize(options) %>)
export default defineNuxtPlugin((app) => {
const options = useRuntimeConfig().public.vWave

const directive = options.directive || 'wave'

const { vWave, vWaveTrigger } = VWave.createLocalWaveDirective(options, app.vueApp)

app.vueApp.directive(directive, {
...vWave,
getSSRProps() {
return {}
}
})

app.vueApp.directive(`${directive}-trigger`, {
...vWaveTrigger,
getSSRProps() {
return {}
}
})
})
29 changes: 0 additions & 29 deletions nuxt/v3/postinstall.js

This file was deleted.

9 changes: 0 additions & 9 deletions nuxt/v3/v-wave.client.ts

This file was deleted.

6 changes: 0 additions & 6 deletions nuxt/v3/v-wave.server.ts

This file was deleted.

Loading

0 comments on commit ee3ea2a

Please sign in to comment.