Last active
January 24, 2023 09:57
-
-
Save kevindoran/d4e587b4e0beb0537b3057f7600f117b to your computer and use it in GitHub Desktop.
Hugo single page template for Anki cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ define "head" }} | |
<link rel="stylesheet" href="{{ "css/anki.css" | relURL }}"> | |
<script> | |
function toggleCard() { | |
btn = document.getElementById("toggle-card-btn") | |
if(btn.textContent == "Show Answer") { | |
document.getElementsByClassName("anki-front")[0].style.display = "none"; | |
document.getElementsByClassName("anki-back")[0].style.display = "block"; | |
btn.textContent = "Hide Answer"; | |
} else { | |
document.getElementsByClassName("anki-front")[0].style.display = "block"; | |
document.getElementsByClassName("anki-back")[0].style.display = "none"; | |
btn.textContent = "Show Answer"; | |
} | |
} | |
</script> | |
{{ end }} | |
{{ define "main" }} | |
<main> | |
<article> | |
{{ partial "breadcrumbs.html" .}} | |
<button id="toggle-card-btn" onclick="toggleCard()">Show Answer</button> | |
<div class="anki-body nightMode"> | |
{{ .Content }} | |
</div> | |
{{ with .Params.tags }} | |
<div> | |
<ul id="tags"> | |
{{ range . }} | |
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li> | |
{{ end }} | |
</ul> | |
</div> | |
{{ end }} | |
<time>{{ .Date.Format "02.01.2006" }}</time> | |
</article> | |
</main> | |
<nav class="prev-next"> | |
{{ if .PrevPage }} | |
<a class="prev-link" href="{{ .PrevPage.Permalink }}?ref=footer">« {{ .PrevPage.Title | truncate 30 "..."}}</a> | |
{{ else }} | |
<a /> | |
{{ end }} | |
</div> | |
<div class="next-link"> | |
{{ if .NextPage }} | |
<a class="next-link" href="{{ .NextPage.Permalink }}?ref=footer">{{ .NextPage.Title | truncate 30 "..." }} »</a> | |
{{ else }} | |
<a /> | |
{{ end }} | |
</div> | |
</nav> | |
{{ end }} |
Blog repo is at https://github.com/kevindoran/www, and the main Anki entry point is the script: https://github.com/kevindoran/www/blob/main/scripts/anki_gen.py
thanks both links redirect to page not found. Maybe it is a private repo?
Sorry. Made it public now.
Thanks alot. I like your anki notes(decks). Maybe if you can add a link of your blog to profile info, It would be easy to locate the blog.
Yea, I can add it. The Anki root ended up here: https://blog.kdoran.com/anki/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @kevindoran do you have repository or demo for publishing anki deck to hugo?