display random taglines on each page load

This commit is contained in:
John Bowdre 2023-08-19 18:07:01 -05:00
parent 288998aac3
commit fc359e9cdd
3 changed files with 45 additions and 1 deletions

View file

@ -10,8 +10,24 @@ palette = "runtimeterror"
# Sidebar: about/bio
[about]
title = "runtimeterror"
description = "Better living through less-bad code."
logo = "images/broken-computer.svg"
taglines = [
"better living through less shitty code",
"bugs are like onions, they have layers",
"bugs, uh, find a way",
"creating new and exciting bugs",
"houston, we have a bug",
"i ain't afraid of no code",
"i see null pointers",
"i'm not a real programmer",
"keep your friends close, but your breakpoints closer",
"may the code be with you",
"ship things and breakfast",
"there's no place like localhost",
"tonight we test in prod",
"why did it have to be bugs",
"you can't handle the exception",
]
# Sidebar: social links
# Available icon sets:

View file

@ -0,0 +1,15 @@
{{ with .Site.Params.about }}
<div class="aside__about">
{{ with .logo }}<img class="about__logo" src="{{ . | absURL }}" alt="Logo">{{ end }}
<h1 class="about__title">{{ .title }}</h1>
{{ partial "tagline.html" . }}
</div>
{{ end }}
<ul class="aside__social-links">
{{ range $item := .Site.Params.socialLinks }}
<li>
<a href="{{ $item.url }}" rel="me" aria-label="{{ $item.title }}" title="{{ $item.title }}"><i class="{{ $item.icon }}" aria-hidden="true"></i></a>&nbsp;
</li>
{{ end }}
</ul>

View file

@ -0,0 +1,13 @@
{{ with . }}
<meta name="taglines" content="{{ .taglines | jsonify }}" />
{{ end }}
<script language="Javascript" type="text/javascript">
var taglines = JSON.parse(document.getElementsByTagName("meta")["taglines"].content);
function getTagline() {
var randIndex = Math.floor(Math.random() * taglines.length);
document.getElementById("tagline").innerHTML = taglines[randIndex];
}
console.log(taglines)
window.addEventListener("pageshow", getTagline);
</script>
<div id="tagline"></div>