You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I first have to say! What a great library! It's so diverse and usable. Thank you!
I do have one question. At the moment; we can use the run() method. The run method expects an config json and this also inits the consent.
My question; is it possible to set defaults before calling the run() method? Maybe already in the build (custom)?
We create lots of website and for the cookiebar it's 80% the same except the type of cookies and colors; so I want to see if we can somehow create a build with defaults that match our config; and override the config that's specific to the client.
Is this possible?
Link the related docs page, if it exists.
No response
The text was updated successfully, but these errors were encountered:
ceesvanegmond
changed the title
[Docs]: Is it possible to create a custom build; with other defaults?
[Docs]: Is it possible to create a custom build; with custom defaults?
Dec 1, 2023
@ceesvanegmond you can do it, but you need to create your own wrapper and a proper merge function to merge the 2 configs. Here is a proof of concept using v3:
index.js
import*asCookieConsentfrom"vanilla-cookieconsent"importdefaultConfigfrom"./defaultConfig";constmergeConfigs=(defaultConfig,userConfig)=>{constmergedConfig={ ...defaultConfig};for(constkeyinuserConfig){if(userConfig.hasOwnProperty(key)){if(typeofuserConfig[key]==='object'&&userConfig[key]!==null&&defaultConfig[key]){mergedConfig[key]=mergeConfigs(defaultConfig[key],userConfig[key]);}else{mergedConfig[key]=userConfig[key];}}}returnmergedConfig;}// Export your custom run methodexportconstrun=async(userConfig={})=>{awaitCookieConsent.run(mergeConfigs(defaultConfig,userConfig));};exportconstacceptService=CookieConsent.acceptCategory;exportconstacceptedCategory=CookieConsent.acceptedCategory;exportconstacceptedService=CookieConsent.acceptedService;// TODO: export the other methods
What is the improvement/update you wish to see?
Hi all,
I first have to say! What a great library! It's so diverse and usable. Thank you!
I do have one question. At the moment; we can use the
run()
method. Therun
method expects an config json and this also inits the consent.My question; is it possible to set defaults before calling the
run()
method? Maybe already in the build (custom)?We create lots of website and for the cookiebar it's 80% the same except the type of cookies and colors; so I want to see if we can somehow create a build with defaults that match our config; and override the config that's specific to the client.
Is this possible?
Link the related docs page, if it exists.
No response
The text was updated successfully, but these errors were encountered: