Documentation

This commit is contained in:
squidfunk 2022-09-18 15:40:38 +02:00
parent 6b1ce14683
commit 06629ffdad
4 changed files with 34 additions and 16 deletions

View File

@ -155,6 +155,9 @@
"properties": { "properties": {
"analytics": { "analytics": {
"$ref": "#/definitions/cookie" "$ref": "#/definitions/cookie"
},
"github": {
"$ref": "#/definitions/cookie"
} }
}, },
"patternProperties": { "patternProperties": {
@ -173,6 +176,16 @@
"checked": true "checked": true
} }
} }
},
{
"label": "github (default)",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/ensuring-data-privacy/#+consent.cookies",
"body": {
"analytics": {
"name": "GitHub",
"checked": true
}
}
} }
] ]
}, },

View File

@ -6,23 +6,23 @@ template: overrides/main.html
Material for MkDocs makes compliance with data privacy regulations very easy, Material for MkDocs makes compliance with data privacy regulations very easy,
as it offers a native [cookie consent] solution to seek explicit consent from 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]. automatically downloaded for [self-hosting].
[cookie consent]: #cookie-consent [cookie consent]: #cookie-consent
[tracking]: setting-up-site-analytics.md [analytics]: setting-up-site-analytics.md
[self-hosting]: #built-in-privacy-plugin [self-hosting]: #built-in-privacy-plugin
## Configuration ## Configuration
### Cookie consent { #cookie-consent } ### Cookie consent
[:octicons-tag-24: 8.4.0][Cookie consent support] · [:octicons-tag-24: 8.4.0][Cookie consent support] ·
:octicons-milestone-24: Default: _none_ · :octicons-milestone-24: Default: _none_ ·
:octicons-beaker-24: Experimental :octicons-beaker-24: Experimental
Material for MkDocs ships a native and extensible cookie consent form which 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`: following to `mkdocs.yml`:
``` yaml ``` yaml
@ -56,10 +56,15 @@ The following properties are available:
[`cookies`](#+consent.cookies){ #+consent.cookies } [`cookies`](#+consent.cookies){ #+consent.cookies }
: :octicons-milestone-24: Default: _none_ This property allows to add custom : :octicons-milestone-24: Default: _none_ This property allows to add custom
cookies or change the initial `checked` state and name of the `analytics` cookies or change the initial `checked` state and name of built-in cookies.
cookie. Each cookie must receive a unique identifier which is used as a key Currently, the following cookies are built-in:
in the `cookies` map, and can be either set to a string, or to a map
defining `name` and `checked` state: - __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" === "Custom cookie name"
@ -95,8 +100,8 @@ The following properties are available:
the `analytics` cookie must be added back explicitly, or analytics the `analytics` cookie must be added back explicitly, or analytics
won't be triggered. won't be triggered.
If Google Analytics was configured via `mkdocs.yml`, the cookie consent will
If Google Analytics was configured via `mkdocs.yml`, the cookie consent will automatically include a setting for the user to disable it. [Custom cookies] automatically include a setting for the user to disable it. [Custom cookies]
can be used from JavaScript. can be used from JavaScript.
[`actions`](#+consent.actions){ #+consent.actions } [`actions`](#+consent.actions){ #+consent.actions }

View File

@ -4,9 +4,9 @@
{% set cookies = config.extra.consent.cookies %} {% set cookies = config.extra.consent.cookies %}
{% if config.extra.analytics and not cookies %} {% if config.extra.analytics and not cookies %}
{% set cookies = { "analytics": "Google Analytics" } %} {% set cookies = { "analytics": "Google Analytics" } %}
{% if "github.com" in config.repo_url %} {% endif %}
{% set _ = cookies.update({ "github": "GitHub" }) %} {% if "github.com" in config.repo_url and "github" not in cookies %}
{% endif %} {% set _ = cookies.update({ "github": "GitHub" }) %}
{% endif %} {% endif %}
{% set actions = config.extra.consent.actions %} {% set actions = config.extra.consent.actions %}
{% if not actions %} {% if not actions %}

View File

@ -24,9 +24,9 @@
{% set cookies = config.extra.consent.cookies %} {% set cookies = config.extra.consent.cookies %}
{% if config.extra.analytics and not cookies %} {% if config.extra.analytics and not cookies %}
{% set cookies = { "analytics": "Google Analytics" } %} {% set cookies = { "analytics": "Google Analytics" } %}
{% if "github.com" in config.repo_url %} {% endif %}
{% set _ = cookies.update({ "github": "GitHub" }) %} {% if "github.com" in config.repo_url and "github" not in cookies %}
{% endif %} {% set _ = cookies.update({ "github": "GitHub" }) %}
{% endif %} {% endif %}
<!-- Determine actions --> <!-- Determine actions -->