I am using hugo 0.126.2 and PaperMod.
I am trying to make a simple page with a button in /content/jetlag/challenge.md that randomly selects a file in /content/challenges/ and opens it.
So pressing the button on https://domain.tld/jetlag/challenge/ could open up https://domain.tld/challenges/7/
Here is what I have in /content/jetlag/challenge.md right now:
---
title: Random Challenge Button
---
## press for random challenge
<html>
<body style="font-size: 20px; text-align: center;">
<button id="randomChallengeButton" class="custom-button">Random Challenge (click to earn coins!)</button>
<script>
document.getElementById("randomChallengeButton").addEventListener("click", function() {
const randomNumber = Math.floor(Math.random() * 100) + 1;
const randomChallengeFile = "challenges/" + randomNumber + ".html";
window.location.href = randomChallengeFile;
});
</script>
</body>
</html>
And my /content/challenges/1.md is:
---
title: "1"
---
# Find a pigeon.
30 pts
This currently doesn’t even render a button at all. Am I missing something? Is there another better way to do this?
Thanks!!