├── renovate.json ├── test ├── fixture │ ├── .env.default │ ├── nuxt.config.js │ └── pages │ │ └── index.vue └── module.test.js ├── .eslintignore ├── commitlint.config.js ├── .gitignore ├── husky.config.js ├── .eslintrc.js ├── babel.config.js ├── .editorconfig ├── jest.config.js ├── lib ├── plugin.js └── module.js ├── LICENSE.md ├── package.json ├── README.md └── CHANGELOG.md /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@nuxtjs" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /test/fixture/.env.default: -------------------------------------------------------------------------------- 1 | ZENDESK_KEY= 2 | ZENDESK_DISABLED= 3 | ZENDESK_HIDE_ON_LOAD= 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # Common 2 | node_modules 3 | dist 4 | .nuxt 5 | coverage 6 | 7 | # Plugin 8 | lib/plugin.js 9 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | '@commitlint/config-conventional' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.iml 3 | .idea 4 | *.log* 5 | .nuxt 6 | .vscode 7 | .DS_Store 8 | coverage 9 | dist 10 | .env 11 | -------------------------------------------------------------------------------- /husky.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | hooks: { 3 | 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS', 4 | 'pre-commit': 'yarn lint', 5 | 'pre-push': 'yarn lint' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | parser: 'babel-eslint', 5 | sourceType: 'module' 6 | }, 7 | extends: [ 8 | '@nuxtjs' 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | '@babel/preset-env', { 5 | targets: { 6 | esmodules: true 7 | } 8 | } 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | collectCoverage: true, 4 | collectCoverageFrom: [ 5 | 'lib/**/*.js', 6 | '!lib/plugin.js' 7 | ], 8 | moduleNameMapper: { 9 | '^~/(.*)$': '/lib/$1', 10 | '^~~$': '', 11 | '^@@$': '', 12 | '^@/(.*)$': '/lib/$1' 13 | }, 14 | transform: { 15 | '^.+\\.js$': 'babel-jest' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/plugin.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Zendesk from '@dansmaculotte/vue-zendesk' 3 | 4 | const KEY = '<%= options.key %>' 5 | const DISABLED = <%= options.disabled %> 6 | const HIDE_ON_LOAD = <%= options.hideOnLoad %> 7 | const SETTINGS = <%= JSON.stringify(options.settings) %> 8 | 9 | export default function (context) { 10 | Vue.use(Zendesk, { 11 | key: KEY, 12 | disabled: DISABLED, 13 | hideOnLoad: HIDE_ON_LOAD, 14 | settings: SETTINGS 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /test/fixture/nuxt.config.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path') 2 | require('dotenv').config({ 3 | path: resolve(__dirname, '.env') 4 | }) 5 | 6 | module.exports = { 7 | rootDir: resolve(__dirname, '../..'), 8 | buildDir: resolve(__dirname, '.nuxt'), 9 | srcDir: __dirname, 10 | render: { 11 | resourceHints: false 12 | }, 13 | modules: ['@@'], 14 | zendesk: { 15 | settings: { 16 | webWidget: { 17 | color: { 18 | theme: '#78a300' 19 | }, 20 | contactForm: { 21 | attachments: false 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/module.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path') 2 | 3 | module.exports = function (moduleOptions) { 4 | const options = Object.assign( 5 | { 6 | key: process.env.ZENDESK_KEY || '', 7 | disabled: process.env.ZENDESK_DISABLED || false, 8 | hideOnLoad: process.env.ZENDESK_HIDE_ON_LOAD || false, 9 | settings: {} 10 | }, 11 | this.options.zendesk, 12 | moduleOptions 13 | ) 14 | 15 | this.addPlugin({ 16 | src: resolve(__dirname, 'plugin.js'), 17 | fileName: 'nuxt-zendesk.js', 18 | ssr: false, 19 | options 20 | }) 21 | } 22 | 23 | module.exports.meta = require('../package.json') 24 | -------------------------------------------------------------------------------- /test/fixture/pages/index.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 37 | -------------------------------------------------------------------------------- /test/module.test.js: -------------------------------------------------------------------------------- 1 | jest.setTimeout(60000) 2 | 3 | const { Nuxt, Builder } = require('nuxt-edge') 4 | const request = require('request-promise-native') 5 | const getPort = require('get-port') 6 | 7 | const config = require('./fixture/nuxt.config') 8 | config.dev = false 9 | 10 | let nuxt, port 11 | 12 | const url = path => `http://localhost:${port}${path}` 13 | const get = path => request(url(path)) 14 | 15 | describe('basic', () => { 16 | beforeAll(async () => { 17 | nuxt = new Nuxt(config) 18 | await nuxt.ready() 19 | await new Builder(nuxt).build() 20 | port = await getPort() 21 | await nuxt.listen(port) 22 | }) 23 | 24 | afterAll(async () => { 25 | await nuxt.close() 26 | }) 27 | 28 | test('render', async () => { 29 | const html = await get('/') 30 | expect(html).toContain('Works!') 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Dans Ma Culotte 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dansmaculotte/nuxt-zendesk", 3 | "version": "0.4.3", 4 | "description": "Nuxt.js module for Zendesk", 5 | "license": "MIT", 6 | "contributors": [ 7 | { 8 | "name": "Gaël Reyrol", 9 | "email": "gael@dansmaculotte.fr" 10 | }, 11 | { 12 | "name": "Romain Touzé", 13 | "email": "romain@dansmaculotte.fr" 14 | } 15 | ], 16 | "main": "lib/module.js", 17 | "repository": "https://github.com/dansmaculotte/nuxt-zendesk", 18 | "publishConfig": { 19 | "access": "public" 20 | }, 21 | "scripts": { 22 | "dev": "nuxt test/fixture", 23 | "lint": "eslint lib test", 24 | "test": "yarn lint && jest", 25 | "release": "yarn test && standard-version && git push --follow-tags && npm publish" 26 | }, 27 | "files": [ 28 | "lib" 29 | ], 30 | "dependencies": { 31 | "@dansmaculotte/vue-zendesk": "0.4.6" 32 | }, 33 | "devDependencies": { 34 | "@babel/core": "latest", 35 | "@babel/preset-env": "latest", 36 | "@commitlint/cli": "latest", 37 | "@commitlint/config-conventional": "11.0.0", 38 | "@nuxtjs/eslint-config": "latest", 39 | "babel-eslint": "latest", 40 | "babel-jest": "latest", 41 | "codecov": "latest", 42 | "dotenv": "latest", 43 | "eslint": "latest", 44 | "eslint-config-standard": "latest", 45 | "eslint-plugin-import": "latest", 46 | "eslint-plugin-jest": "latest", 47 | "eslint-plugin-node": "latest", 48 | "eslint-plugin-promise": "latest", 49 | "eslint-plugin-standard": "5.0.0", 50 | "eslint-plugin-vue": "latest", 51 | "get-port": "latest", 52 | "husky": "latest", 53 | "jest": "latest", 54 | "nuxt-edge": "latest", 55 | "request": "latest", 56 | "request-promise-native": "1.0.9", 57 | "standard-version": "latest" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nuxt-zendesk 2 | 3 | [![npm version][npm-version-src]][npm-version-href] 4 | [![npm downloads][npm-downloads-src]][npm-downloads-href] 5 | [![Dependencies][david-dm-src]][david-dm-href] 6 | [![Standard JS][standard-js-src]][standard-js-href] 7 | 8 | > Nuxt.js module for Zendesk 9 | 10 | This module allows to automatically add Zendesk Web Widget. 11 | Please refer [vue-zendesk](https://github.com/dansmaculotte/vue-zendesk) plugin for configurations. 12 | 13 | [📖 **Release Notes**](./CHANGELOG.md) 14 | 15 | ## Setup 16 | 17 | 1. Add the `@dansmaculotte/nuxt-zendesk` dependency with `yarn` or `npm` to your project 18 | 2. Add `@dansmaculotte/nuxt-zendesk` to the `modules` section of `nuxt.config.js` 19 | 3. Configure it: 20 | 21 | ```js 22 | { 23 | modules: [ 24 | // Simple usage 25 | '@dansmaculotte/nuxt-zendesk', 26 | 27 | // With options 28 | [ 29 | '@dansmaculotte/nuxt-zendesk', 30 | { /* module options */ } 31 | ], 32 | ], 33 | 34 | // Or with global options 35 | zendesk: { 36 | key: '', 37 | disabled: false, 38 | settings: { 39 | webWidget: { 40 | color: { 41 | theme: '#78a300' 42 | } 43 | } 44 | } 45 | } 46 | } 47 | ``` 48 | 49 | ## Options 50 | 51 | ### key 52 | 53 | - Type: `String` 54 | - Default: `process.env.ZENDESK_KEY || ''` 55 | 56 | ### disabled 57 | 58 | - Type: `Boolean` 59 | - Default: `process.env.ZENDESK_DISABLED || false'` 60 | 61 | ### hideOnLoad 62 | 63 | - Type: `Boolean` 64 | - Default : `process.env.ZENDESK_HIDE_ON_LOAD || false` 65 | 66 | ### settings 67 | 68 | This option comes directly from [Zendesk documentation](https://developer.zendesk.com/embeddables/docs/widget/settings). 69 | 70 | - Type: `Object` 71 | - Default: `{}` 72 | 73 | ## Development 74 | 75 | 1. Clone this repository 76 | 2. Install dependencies using `yarn install` or `npm install` 77 | 3. Start development server using `npm run dev` 78 | 79 | ## License 80 | 81 | [MIT License](./LICENSE.md) 82 | 83 | 84 | [npm-downloads-src]: https://img.shields.io/npm/dt/@dansmaculotte/nuxt-zendesk.svg?style=flat-square 85 | [npm-downloads-href]: https://npmjs.com/package/@dansmaculotte/nuxt-zendesk 86 | 87 | [npm-version-src]: https://img.shields.io/npm/v/@dansmaculotte/nuxt-zendesk/latest.svg?style=flat-square 88 | [npm-version-href]: https://npmjs.com/package/@dansmaculotte/nuxt-zendesk 89 | 90 | [david-dm-src]: https://david-dm.org/dansmaculotte/nuxt-zendesk/status.svg?style=flat-square 91 | [david-dm-href]: https://david-dm.org/dansmaculotte/nuxt-zendesk 92 | 93 | [standard-js-src]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square 94 | [standard-js-href]: https://standardjs.com 95 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [0.4.3](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.4.2...v0.4.3) (2022-07-20) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * update browserslist ([9b403e3](https://github.com/dansmaculotte/nuxt-zendesk/commit/9b403e31141bc3b93a6000bc4eab4defdbe35c2e)) 11 | 12 | ### [0.4.2](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.4.1...v0.4.2) (2021-05-25) 13 | 14 | ### [0.4.1](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.4.0...v0.4.1) (2020-05-28) 15 | 16 | 17 | ### Bug Fixes 18 | 19 | * update vue-zendesk ([d975af8](https://github.com/dansmaculotte/nuxt-zendesk/commit/d975af80f21f13ef89def3af1464dbdd972138d9)) 20 | 21 | ## [0.4.0](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.5...v0.4.0) (2020-03-27) 22 | 23 | 24 | ### Features 25 | 26 | * upgrade vue-zendesk to 0.4.0 ([046ead6](https://github.com/dansmaculotte/nuxt-zendesk/commit/046ead6dfe5c087e9eabebf2ed32f5c55e4e7e46)) 27 | 28 | ### [0.3.5](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.4...v0.3.5) (2020-01-14) 29 | 30 | 31 | ### Bug Fixes 32 | 33 | * update vue-zendesk ([99563a4](https://github.com/dansmaculotte/nuxt-zendesk/commit/99563a45509764740ded7e6ff10795461248202c)) 34 | 35 | ### [0.3.4](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.3...v0.3.4) (2020-01-14) 36 | 37 | 38 | ### Bug Fixes 39 | 40 | * update dependency to vue-zendesk ([900fa91](https://github.com/dansmaculotte/nuxt-zendesk/commit/900fa9192de6f3bed000debf0a5b1f3a3842e7bb)) 41 | 42 | ### [0.3.3](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.2...v0.3.3) (2019-08-29) 43 | 44 | 45 | ### Features 46 | 47 | * add hideOnLoad option ([133cb22](https://github.com/dansmaculotte/nuxt-zendesk/commit/133cb22)) 48 | 49 | ### [0.3.2](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.1...v0.3.2) (2019-07-18) 50 | 51 | 52 | 53 | ## [0.3.1](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.3.0...v0.3.1) (2019-05-04) 54 | 55 | 56 | ### Bug Fixes 57 | 58 | * missing declared settings to prevent error ([5dca518](https://github.com/dansmaculotte/nuxt-zendesk/commit/5dca518)) 59 | 60 | 61 | 62 | # [0.3.0](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.2.0...v0.3.0) (2019-05-03) 63 | 64 | 65 | ### Features 66 | 67 | * add gdpr compliance from vue-zendesk ([a0b7ac4](https://github.com/dansmaculotte/nuxt-zendesk/commit/a0b7ac4)) 68 | 69 | 70 | 71 | # [0.2.0](https://github.com/dansmaculotte/nuxt-zendesk/compare/v0.1.0...v0.2.0) (2019-04-24) 72 | 73 | 74 | ### Features 75 | 76 | * use vue-zendesk plugin ([fe8768f](https://github.com/dansmaculotte/nuxt-zendesk/commit/fe8768f)) 77 | 78 | 79 | 80 | # 0.1.0 (2019-04-20) 81 | 82 | 83 | ### Features 84 | 85 | * add zendesk script to head and update test ([f9c4730](https://github.com/dansmaculotte/nuxt-zendesk/commit/f9c4730)) 86 | --------------------------------------------------------------------------------