diff --git a/docs/schema/extra.json b/docs/schema/extra.json index b4f657cf6..67a837bb7 100644 --- a/docs/schema/extra.json +++ b/docs/schema/extra.json @@ -155,6 +155,9 @@ "properties": { "analytics": { "$ref": "#/definitions/cookie" + }, + "github": { + "$ref": "#/definitions/cookie" } }, "patternProperties": { @@ -173,6 +176,16 @@ "checked": true } } + }, + { + "label": "github (default)", + "markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/ensuring-data-privacy/#+consent.cookies", + "body": { + "analytics": { + "name": "GitHub", + "checked": true + } + } } ] }, diff --git a/docs/setup/ensuring-data-privacy.md b/docs/setup/ensuring-data-privacy.md index cf2ba7306..e6a5a41da 100644 --- a/docs/setup/ensuring-data-privacy.md +++ b/docs/setup/ensuring-data-privacy.md @@ -6,23 +6,23 @@ template: overrides/main.html Material for MkDocs makes compliance with data privacy regulations very easy, as it offers a native [cookie consent] solution to seek explicit consent from -users before setting up [tracking]. Additionally, external assets can be +users before setting up [analytics]. Additionally, external assets can be automatically downloaded for [self-hosting]. [cookie consent]: #cookie-consent - [tracking]: setting-up-site-analytics.md + [analytics]: setting-up-site-analytics.md [self-hosting]: #built-in-privacy-plugin ## Configuration -### Cookie consent { #cookie-consent } +### Cookie consent [:octicons-tag-24: 8.4.0][Cookie consent support] · :octicons-milestone-24: Default: _none_ · :octicons-beaker-24: Experimental Material for MkDocs ships a native and extensible cookie consent form which -asks the user for consent prior to sending any data via analytics. Add the +asks the user for consent prior to sending requests to third parties. Add the following to `mkdocs.yml`: ``` yaml @@ -56,10 +56,15 @@ The following properties are available: [`cookies`](#+consent.cookies){ #+consent.cookies } : :octicons-milestone-24: Default: _none_ – This property allows to add custom - cookies or change the initial `checked` state and name of the `analytics` - cookie. Each cookie must receive a unique identifier which is used as a key - in the `cookies` map, and can be either set to a string, or to a map - defining `name` and `checked` state: + cookies or change the initial `checked` state and name of built-in cookies. + Currently, the following cookies are built-in: + + - __Google Analytics__ – `analytics` (enabled by default) + - __GitHub__ – `github` (enabled by default) + + Each cookie must receive a unique identifier which is used as a key in the + `cookies` map, and can be either set to a string, or to a map defining + `name` and `checked` state: === "Custom cookie name" @@ -95,8 +100,8 @@ The following properties are available: the `analytics` cookie must be added back explicitly, or analytics won't be triggered. - - If Google Analytics was configured via `mkdocs.yml`, the cookie consent will automatically include a setting for the user to disable it. [Custom cookies] + If Google Analytics was configured via `mkdocs.yml`, the cookie consent will + automatically include a setting for the user to disable it. [Custom cookies] can be used from JavaScript. [`actions`](#+consent.actions){ #+consent.actions } diff --git a/material/partials/consent.html b/material/partials/consent.html index f23b9f1cc..e909521e7 100644 --- a/material/partials/consent.html +++ b/material/partials/consent.html @@ -4,9 +4,9 @@ {% set cookies = config.extra.consent.cookies %} {% if config.extra.analytics and not cookies %} {% set cookies = { "analytics": "Google Analytics" } %} - {% if "github.com" in config.repo_url %} - {% set _ = cookies.update({ "github": "GitHub" }) %} - {% endif %} +{% endif %} +{% if "github.com" in config.repo_url and "github" not in cookies %} + {% set _ = cookies.update({ "github": "GitHub" }) %} {% endif %} {% set actions = config.extra.consent.actions %} {% if not actions %} diff --git a/src/partials/consent.html b/src/partials/consent.html index f77347dce..4aad2e664 100644 --- a/src/partials/consent.html +++ b/src/partials/consent.html @@ -24,9 +24,9 @@ {% set cookies = config.extra.consent.cookies %} {% if config.extra.analytics and not cookies %} {% set cookies = { "analytics": "Google Analytics" } %} - {% if "github.com" in config.repo_url %} - {% set _ = cookies.update({ "github": "GitHub" }) %} - {% endif %} +{% endif %} +{% if "github.com" in config.repo_url and "github" not in cookies %} + {% set _ = cookies.update({ "github": "GitHub" }) %} {% endif %}