Skip to content

Commit

Permalink
feat: runtime config (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Nikolay Baskov <baskov@adv.ru>
  • Loading branch information
3 people authored Feb 2, 2021
1 parent 769ae67 commit e090317
Show file tree
Hide file tree
Showing 3 changed files with 3,722 additions and 1,258 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ using top level options
}
```

## Runtime config

```js
{
publicRuntimeConfig: {
recaptcha: {
/* reCAPTCHA options */
siteKey: process.env.RECAPTCHA_SITE_KEY // for example
}
}
}
```

## Usage

### reCAPTCHA v2
Expand Down
10 changes: 8 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ReCaptcha {
reject(errorMessage)
}
}

}
})
}
Expand Down Expand Up @@ -167,6 +167,12 @@ class ReCaptcha {
}

export default function (_, inject) {
const { recaptcha = {} } = _.$config || {}
const options = {
...<%= serialize(options) %>,
...recaptcha,
}

Vue.component('Recaptcha', () => import('./recaptcha.vue'))
inject('recaptcha', new ReCaptcha(<%= serialize(options) %>))
inject('recaptcha', new ReCaptcha(options))
}
Loading

0 comments on commit e090317

Please sign in to comment.