diff --git a/README.md b/README.md index 8eb0288..7561d85 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,18 @@ Use specific directives: Vue.directive('observe-visibility', VueObserveVisibility.ObserveVisibility) ``` +## Nuxt.js + +Add `vue-observe-visibility/nuxt` to the modules section of `nuxt.config.js` + +```js +{ + modules: [ + 'vue-observe-visibility/nuxt' + ] +} +``` + # Usage The `v-observe-visibility` directive is very easy to use. Just pass a function as the value: diff --git a/nuxt/index.js b/nuxt/index.js new file mode 100644 index 0000000..82fbb39 --- /dev/null +++ b/nuxt/index.js @@ -0,0 +1,11 @@ +const { resolve } = require('path') + +module.exports = function nuxtVueObserveVisibility() { + this.addPlugin({ + ssr: false, + src: resolve(__dirname, 'plugin.js'), + fileName: 'vue-observe-visibility.js' + }) +} + +module.exports.meta = require('../package.json') diff --git a/nuxt/plugin.js b/nuxt/plugin.js new file mode 100644 index 0000000..af8143d --- /dev/null +++ b/nuxt/plugin.js @@ -0,0 +1,4 @@ +import Vue from 'vue' +import VueObserveVisibility from 'vue-observe-visibility' + +Vue.use(VueObserveVisibility)