diff --git a/packages/cookie-universal-nuxt/README.md b/packages/cookie-universal-nuxt/README.md index 075078d..660d51c 100644 --- a/packages/cookie-universal-nuxt/README.md +++ b/packages/cookie-universal-nuxt/README.md @@ -14,6 +14,7 @@ You can use `cookie-universal-nuxt` to set, get and remove cookies in both clien Add `cookie-universal-nuxt` to `nuxt.config.js`: +### Simple usage ```js { // To make it work for SSR, remember to set `ssr: true` and `target: 'server'` @@ -21,15 +22,41 @@ Add `cookie-universal-nuxt` to `nuxt.config.js`: target: 'server', modules: [ - // Simple usage 'cookie-universal-nuxt', + ] +} +``` + +### With options +```js +{ + // To make it work for SSR, remember to set `ssr: true` and `target: 'server'` + ssr: true, + target: 'server', - // With options + modules: [ ['cookie-universal-nuxt', { alias: 'cookiz' }], ] } ``` +### With top-level options +```js +{ + // To make it work for SSR, remember to set `ssr: true` and `target: 'server'` + ssr: true, + target: 'server', + + modules: [ + 'cookie-universal-nuxt', + ] + + cookieUniversalNuxt: { + alias: 'cookiz' + } +} +``` + ## ParseJSON diff --git a/packages/cookie-universal-nuxt/lib/module.js b/packages/cookie-universal-nuxt/lib/module.js index 22fd603..6095e54 100644 --- a/packages/cookie-universal-nuxt/lib/module.js +++ b/packages/cookie-universal-nuxt/lib/module.js @@ -5,7 +5,8 @@ module.exports = async function module (moduleOptions) { alias: 'cookies', parseJSON: true } - const options = Object.assign({}, defaults, moduleOptions) + const options = Object.assign({}, defaults, this.options.cookieUniversalNuxt, moduleOptions) + this.addPlugin({ src: resolve(__dirname, './templates/cookie-universal-nuxt.js'),