Skip to content

Commit

Permalink
added european cdn option
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-gx committed Nov 10, 2024
1 parent 8543e98 commit 40ddd06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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 40ddd06

Please sign in to comment.