Fix cookie button.

The button is now implemented via a neat shortcode
This commit is contained in:
moanos [he/him] 2021-05-30 22:24:37 +02:00
parent bed96fc7ed
commit 65fbb83fe6
2 changed files with 27 additions and 19 deletions

View File

@ -3,7 +3,7 @@ title: "Why Hyteck"
date: 2019-09-16T18:18:10+02:00
draft: false
image: ""
categrories: [English]
categories: ['English', 'me']
tags: ['about']
---
@ -29,23 +29,7 @@ pronounciation is a Homophone of Tech.
The Hy stayed as I always had a close connection to water.
I feel like I overexplained this a bit, so poor you if you read till the end.
<script>
function createCookie(name, value, days){
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/; samesite=strict;";
}
</script>
Have a <button onclick="createCookie('achievement', 'TLDR_resistant', 365)">cookie</button>
However, you earned a {{< cookie_button achievement TLDR_restistant cookie>}}!

View File

@ -0,0 +1,24 @@
<!---
Adds a button that, when you click it stores a cookie for the user.
Use as {{< cookie_button cookie_key cookie_value button_text>}}
-->
<script>
function createCookie(name, value, days){
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/; samesite=strict;";
}
</script>
<button onclick="createCookie('{{ index .Params 0}}', '{{ index .Params 1}}', 365)">{{ index .Params 2}}</button>