Skip to content

Commit

Permalink
Merge pull request #9 from markus-gx/feat/eu-only-cdn
Browse files Browse the repository at this point in the history
added european cdn option
  • Loading branch information
markus-gx authored Nov 10, 2024
2 parents 8543e98 + f953863 commit 53550f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default defineNuxtConfig({
stealthMode: false, //default false
silentMode: false, //default false
language: 'YOUR_DEFAULT_LANGUAGE', //default null
useEuropeanCDN: true //default true - If the European CDN should be used
}
})
```
Expand Down
18 changes: 10 additions & 8 deletions docs/content/1.introduction/2.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ export default defineNuxtConfig({
stealthMode: false,
silentMode: false,
language: null,
resetTabIndex: false
resetTabIndex: false,
useEuropeanCDN: true
}
...
})
```

::

| **Key** | **Type** | **Default** | **Description** |
| ---------------------------- | ---------- | --------------------- | ---------------------------------------------------------------------------------------------------- |
| `apiKey` | `string` | null | The API Key for your Cookie First Banner |
| `stealthMode` | `boolean` | false | Deactivates the banner and only enables cookie rendering component
| `silentMode` | `boolean` | false | Deactivates all browser/console information |
| `language` | `string` | null | ISO-639-1 Lang code for the banner language. If no langauge is set, the browser language is used. |
| `resetTabIndex` | `boolean` | false | Resets the Tab Index of all banner elemments to zero (`tabindex=0` \| Default is `tabindex=1`) Useful if you need to get some more lighthouse accessibily score points.
| **Key** | **Type** | **Default** | **Description** |
| ---------------------------- | ---------- | --------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apiKey` | `string` | null | The API Key for your Cookie First Banner |
| `stealthMode` | `boolean` | false | Deactivates the banner and only enables cookie rendering component
| `silentMode` | `boolean` | false | Deactivates all browser/console information |
| `language` | `string` | null | ISO-639-1 Lang code for the banner language. If no langauge is set, the browser language is used. |
| `resetTabIndex` | `boolean` | false | Resets the Tab Index of all banner elemments to zero (`tabindex=0` \| Default is `tabindex=1`) Useful if you need to get some more lighthouse accessibily score points.
| `useEuropeanCDN` | `boolean` | true | If the European CDN should be used. If set to false, the global CDN of CookieFirst is used. |

5 changes: 4 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ModuleOptions {
silentMode?: boolean
language?: string // 2-letter ISO 639-1 code
resetTabIndex?: boolean
useEuropeanCDN?: boolean
}

export default defineNuxtModule<ModuleOptions>({
Expand All @@ -20,7 +21,9 @@ export default defineNuxtModule<ModuleOptions>({
configKey: 'cookieFirst',
},
// Default configuration options of the Nuxt module
defaults: {},
defaults: {
useEuropeanCDN: true,
},
setup(options: ModuleOptions, nuxt: Nuxt) {
const resolver = createResolver(import.meta.url)
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/plugin.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ export default defineNuxtPlugin(() => {
silentMode,
language,
resetTabIndex,
useEuropeanCDN,
},
},
} = useRuntimeConfig()

if (apiKey) {
const URL = useEuropeanCDN
? 'https://consent-eu.cookiefirst.com/banner.js?'
: 'https://consent.cookiefirst.com/banner.js?'
useHead({
script: [
{
src: 'https://consent.cookiefirst.com/banner.js?' + concatAndEncodeURLParams({
src: URL + concatAndEncodeURLParams({
'cookiefirst-key': apiKey,
'stealth-mode': stealthMode,
'silent-mode': silentMode,
Expand Down

0 comments on commit 53550f4

Please sign in to comment.