Skip to content

Commit 6ca1f4d

Browse files
Bring back cookieconsent
It was removed during the transition to VitePress. We do need to add it back given the structure of the site. The old plugin is back, but with some changes: - instead of static banner at top, it is a floating box on the bottom right - a custom CSS override was added to adapt the theming of the box to VitePress - make translatable by adding a locale-specific head that imports the JS file with a hack to add custom parameters for the message content - minor rice For now this is only added to the English page. As the translations for it start to fill, we can enable for remaining languages.
1 parent 064fba2 commit 6ca1f4d

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

docs/.vitepress/config.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ export default defineConfig({
1515
description: "A complete guide to 3DS custom firmware",
1616
head: [
1717
['link', { rel: 'icon', href: '/images/site-config/favicon.ico' }],
18+
['link', {
19+
rel: 'stylesheet',
20+
href: 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.1/cookieconsent.min.css',
21+
integrity: "sha512-LQ97camar/lOliT/MqjcQs5kWgy6Qz/cCRzzRzUCfv0fotsCTC9ZHXaPQmJV8Xu/PVALfJZ7BDezl5lW3/qBxg==",
22+
crossorigin: "anonymous",
23+
referrerpolicy: "no-referrer"
24+
}],
25+
['script', {
26+
src: 'https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.1/cookieconsent.min.js',
27+
integrity: "sha512-yXXqOFjdjHNH1GND+1EO0jbvvebABpzGKD66djnUfiKlYME5HGMUJHoCaeE4D5PTG2YsSJf6dwqyUUvQvS0vaA==",
28+
crossorigin: "anonymous",
29+
referrerpolicy: "no-referrer"
30+
}],
31+
['link', {
32+
rel: 'stylesheet',
33+
href: '/assets/css/cookieconsent.css'
34+
}],
1835
['script', { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-760Y60FQ3T' }],
1936
['script', {}, `window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-760Y60FQ3T');`]
2037
],

docs/.vitepress/i18n/en_US.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,14 @@ export default {
269269
label: "English",
270270
title: localeData.title,
271271
description: localeData.description,
272-
themeConfig: themeConfig
272+
themeConfig: themeConfig,
273+
head: [
274+
['script',
275+
{
276+
id: "cookieconsent_i18n",
277+
content: localeData.cookieConsent,
278+
src: "/assets/js/cookieconsent.js"
279+
},
280+
]
281+
],
273282
}

docs/.vitepress/i18n/strings/en_US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"lightModeSwitchTitle": "Switch to light theme",
88
"sidebarMenuLabel": "Menu",
99
"returnToTopLabel": "Return to top",
10+
"cookieConsent": "This website uses cookies to display the current guide progress on the sidebar and otherwise enhance the site.",
1011

1112
"guide": "Guide",
1213
"extras": "Extras",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.cc-window {
2+
color: var(--vp-c-text-1);
3+
background-color: var(--vp-c-gray-1);
4+
}
5+
6+
.cc-link {
7+
color: var(--vp-c-brand-1);
8+
}
9+
10+
.cc-link:visited {
11+
color: var(--vp-c-brand-1);
12+
}
13+
14+
.cc-floating {
15+
border: 2px solid var(--vp-c-border);
16+
}
17+
18+
.cc-btn {
19+
font-weight: bold;
20+
font-size: 100%;
21+
cursor: pointer;
22+
border: 2px solid var(--vp-c-border);
23+
padding: .25em;
24+
border-radius: 4px;
25+
appearance: auto;
26+
}
27+
28+
.cc-btn:hover {
29+
background-color: var(--vp-c-gray-3);
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
window.addEventListener("load", function(){
2+
window.cookieconsent.initialise({
3+
"theme": "classic",
4+
"position": "bottom-right",
5+
"content": {
6+
"message": document.getElementById("cookieconsent_i18n").getAttribute("content")
7+
}
8+
})});

0 commit comments

Comments
 (0)