jop-software / astro-cookieconsent

Simple to use Cookie Consent for Astro
GNU General Public License v3.0
42 stars 3 forks source link

Can't configure callbacks #13

Open docapi opened 8 months ago

docapi commented 8 months ago

The config doesn't accept functions, so it's not possible to define the callback "onFirstAction", "onAccept" and "onChange".

e.g.

onFirstAction: function(){
    console.log('onFirstAction fired');
},
nikolas-nelson commented 7 months ago

Same problem

cngJo commented 5 months ago

Are you passing the function directly in the Astro config?

That's not possible as far as I'm aware, but I haven't tried to be honest. I'll find some time the next days to play around with this. Probably we need to build some sort of runtime hook system to work with those handlers. I'll think about this.

docapi commented 5 months ago

If you have functions in your cookie configuration file, JSON.stringify will omit them. So maybe you have to add a special convert job which skips the JSON.stringify-part for functions.

Or do you see an other way to inject the callbacks?