dustin.web/templates/index.html

76 lines
2.6 KiB
HTML

{% extends "base.html" %}
{% block init %}
{% set page_class = "index" %}
{% endblock%}
{% block links %}
<link rel="alternate" type="application/atom+xml" title="Atom Feed"
href="{{ get_url(path="atom.xml", trailing_slash=false) }}">
{% endblock %}
{% block header %}{% endblock %}
{% block content %}
<section class="home">
<h1 class="my-name">Dustin C. Hatch</h1>
<ul class="my-attributes">
<li>Software Engineer</li>
<li>Linux Administrator</li>
<li>Tinkerer</li>
<li>Writer</li>
</ul>
<div class="recent-posts">
<h2>Recent Posts</h2>
{% set blog = get_section(path="blog/_index.md") %}
{% for page in blog.pages | slice(end=3) %}
<a href="{{ page.path }}" class="post-summary">
<h3 class="post-title">{{ page.title }}</h3>
<div class="post-date">
<time datetime="{{ page.date }}">{{ page.date | date(format="%d %b %Y") }}</time>
</div>
{% if page.summary %}
<p>{{ page.summary }}</p>
{% else %}
<p>{{ page.content | striptags | split(pat=" ") | slice(end=20) | join(sep=" ") | safe }}{% if page.word_count > 20 %}…{% endif %}</p>
{% endif %}
</a>
{% endfor %}
</div>
</section>
{% endblock %}
{% block after_content %}
<div id="songquote"></div>
<script>
(function() {
window.addEventListener('DOMContentLoaded', (event) => {
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', () => {
var songs = JSON.parse(xhr.responseText);
var idx = Math.floor(Math.random() * (songs.length - 1));
var song = songs[idx];
var elm = document.querySelector('#songquote');
var elm_quote = document.createElement('span');
elm_quote.className = 'quote';
elm_quote.appendChild(document.createTextNode("“" + song.quote + "”"));
elm.appendChild(elm_quote);
elm.appendChild(document.createTextNode(" — "));
var elm_citation = document.createElement('span');
elm_citation.className = 'citation';
elm_citation.title = song.album + " (" + song.year + ")";
var elm_title = document.createElement('span');
elm_title.className = 'title';
elm_title.appendChild(document.createTextNode(song.title));
elm_citation.appendChild(elm_title);
elm_citation.appendChild(document.createTextNode(" by "));
var elm_artist = document.createElement('span');
elm_artist.className = 'artist';
elm_artist.appendChild(document.createTextNode(song.artist));
elm_citation.appendChild(elm_artist);
elm.appendChild(elm_citation);
elm.style.display = 'block';
});
xhr.open('GET', 'songquotes.json');
xhr.send();
})
})();
</script>
{% endblock %}