Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit fa26510

Browse files
Added custom cookies
1 parent a84e252 commit fa26510

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Overview
3+
---
4+
5+
# Implementing custom cookies
6+
7+
This example shows how to customize a cookie consent and checking if users
8+
accepted it.
9+
10+
Download example as archive:
11+
12+
[Download .zip][Download]{ .md-button .md-button--priary }
13+
14+
Unzip archive, change to the folder and enter:
15+
16+
``` bash
17+
pip install -r requirements.txt
18+
mkdocs serve
19+
```
20+
21+
[Download]: https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/mkdocs-material/examples/tree/master/examples/tags
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var consent = __md_get("__consent")
2+
if (consent && consent.custom) {
3+
/* The user accepted the cookie */
4+
alert$.next("Custom cookie was accepted")
5+
}

packages/custom-cookies/mkdocs.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2022 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
# -----------------------------------------------------------------------------
22+
# Recommended: set up configuration validation, see https://bit.ly/3WT2GkR
23+
# -----------------------------------------------------------------------------
24+
25+
# Project information
26+
site_name: Implementing custom cookies
27+
28+
# Repository
29+
repo_name: mkdocs-material/examples
30+
repo_url: https://github.com/mkdocs-material/examples
31+
edit_uri: edit/master/examples/custom-cookies/docs
32+
33+
# Theme
34+
theme:
35+
name: material
36+
features:
37+
- navigation.sections
38+
39+
extra_javascript:
40+
- javascripts/consent.js
41+
42+
extra:
43+
consent:
44+
cookies:
45+
analytics: Google Analytics
46+
custom: Custom cookie
47+
actions:
48+
- accept
49+
- manage
50+
51+
copyright: >
52+
Copyright &copy; 2016 - 2022 Martin Donath –
53+
<a href="#__consent">Change cookie settings</a>
54+
55+
# Markdown extensions
56+
markdown_extensions:
57+
- attr_list
58+
- toc:
59+
permalink: true
60+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2022 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
mkdocs-material

0 commit comments

Comments
 (0)