From 40ddd0616cb4f24bc738ff1dbfac176eaedec406 Mon Sep 17 00:00:00 2001 From: Markus Geilehner Date: Sun, 10 Nov 2024 13:42:50 +0100 Subject: [PATCH 1/2] added european cdn option --- src/module.ts | 5 ++++- src/runtime/plugin.client.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/module.ts b/src/module.ts index a42447d..8f24b83 100644 --- a/src/module.ts +++ b/src/module.ts @@ -12,6 +12,7 @@ export interface ModuleOptions { silentMode?: boolean language?: string // 2-letter ISO 639-1 code resetTabIndex?: boolean + useEuropeanCDN?: boolean } export default defineNuxtModule({ @@ -20,7 +21,9 @@ export default defineNuxtModule({ 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)) diff --git a/src/runtime/plugin.client.ts b/src/runtime/plugin.client.ts index 8d44174..460ed52 100644 --- a/src/runtime/plugin.client.ts +++ b/src/runtime/plugin.client.ts @@ -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, From f953863ee317cd22d41044b5481db1b1d16e46af Mon Sep 17 00:00:00 2001 From: Markus Geilehner Date: Sun, 10 Nov 2024 13:46:39 +0100 Subject: [PATCH 2/2] updated cos --- README.md | 1 + docs/content/1.introduction/2.configuration.md | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e67bdb9..44c0b75 100644 --- a/README.md +++ b/README.md @@ -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 } }) ``` diff --git a/docs/content/1.introduction/2.configuration.md b/docs/content/1.introduction/2.configuration.md index f749c99..7e8651d 100644 --- a/docs/content/1.introduction/2.configuration.md +++ b/docs/content/1.introduction/2.configuration.md @@ -21,7 +21,8 @@ export default defineNuxtConfig({ stealthMode: false, silentMode: false, language: null, - resetTabIndex: false + resetTabIndex: false, + useEuropeanCDN: true } ... }) @@ -29,11 +30,12 @@ export default defineNuxtConfig({ :: -| **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. |