@@ -547,15 +547,25 @@ const url ="https://polyfill.io/v3/polyfill.min.js"
547
547
### Custom cookies
548
548
549
549
If you've customized the [ cookie consent] and added a ` custom ` cookie, the user
550
- will be prompted to accept your custom cookie. Use [ additional JavaScript] to
551
- check whether the user accepted it:
550
+ will be prompted to accept or reject your custom cookie. Once the user accepts
551
+ or rejects the cookie consent, or [ changes the settings] , the page reloads[ ^ 1 ] .
552
+ Use [ additional JavaScript] to query the result:
553
+
554
+ [ ^ 1 ] :
555
+ We reload the page to make interop with custom cookies simpler. If Material
556
+ for MkDocs would implement a callback-based approach, the author would need
557
+ to make sure to correctly update all scripts that use cookies. Additionally,
558
+ the cookie consent is only answered initially, which is why we consider this
559
+ to be a good trade-off of DX and UX.
552
560
553
561
=== ":octicons-file-code-16: ` docs/javascripts/consent.js ` "
554
562
555
563
``` js
556
564
var consent = __md_get("__consent")
557
565
if (consent && consent.custom) {
558
566
/* The user accepted the cookie */
567
+ } else {
568
+ /* The user rejected the cookie */
559
569
}
560
570
```
561
571
@@ -567,3 +577,4 @@ check whether the user accepted it:
567
577
```
568
578
569
579
[ additional JavaScript ] : ../customization.md#additional-javascript
580
+ [ changes the settings ] : #change-cookie-settings
0 commit comments