aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_config.yml4
-rw-r--r--_includes/posts.html13
-rw-r--r--_layouts/default.html24
-rw-r--r--_plugins/datefmt.rb8
-rw-r--r--_plugins/meta.rb31
-rw-r--r--_sass/layout.scss1
-rw-r--r--_sass/theme.scss35
-rwxr-xr-x_scripts/postinfo6
-rwxr-xr-x_scripts/repoinfo2
-rw-r--r--index.md2
-rw-r--r--posts/by-date.md12
-rw-r--r--posts/by-title.md12
12 files changed, 129 insertions, 21 deletions
diff --git a/_config.yml b/_config.yml
index e805b30..f2546ec 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,4 +1,4 @@
-title: "Loek's Blog"
+title: blog.pipeframe.xyz
domain: blog.pipeframe.xyz
exclude:
- makefile
@@ -16,7 +16,7 @@ defaults:
lang: en
toc: true
output: true
- footer: true
+ post: true
markdown: kramdown
sass:
style: compressed
diff --git a/_includes/posts.html b/_includes/posts.html
new file mode 100644
index 0000000..692e6ad
--- /dev/null
+++ b/_includes/posts.html
@@ -0,0 +1,13 @@
+<table class="plainlink" width="100%">
+ <tr>
+ <th><a href="by-date.html" class="{% if include.sort == "date" %}sortcolumn{% endif %}">date</a></th>
+ <th><a href="by-title.html" class="{% if include.sort == "title" %}sortcolumn{% endif %}">title</a></th>
+ </tr>
+ {% assign posts = site.items | sort: include.sort %}
+ {% for post in posts %}
+ <tr>
+ <td>{{ post.date | datefmt }}</td>
+ <td><a href="{{ post.url }}">{{ post.title }}</a></td>
+ </tr>
+ {% endfor %}
+</table>
diff --git a/_layouts/default.html b/_layouts/default.html
index 46cf1e9..efb2c87 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -7,10 +7,10 @@
<meta property='og:site_name' content='{{ page.date }}' />
<meta property='og:title' content='{{ page.title }}' />
<meta property='og:description' content='{{ page.subtitle }}' />
- {% if page.id == "index" %}
- <title>{{ site.title }}</title>
- {% else %}
+ {% if page.post %}
<title>{{ page.title }} - {{ site.title }}</title>
+ {% else %}
+ <title>{{ site.title }}</title>
{% endif %}
</head>
<body>
@@ -25,7 +25,7 @@
<a href="/posts" class="item {% if page.id == "posts" %}active{% endif %}">posts</a>
<span class="right">
{% if page.toc %}<a href="#" class="item">top</a>{% endif %}
- {% if page.footer %}<a href="#footer" class="item">bottom</a>{% endif %}
+ {% if page.post %}<a href="#footer" class="item">bottom</a>{% endif %}
</span>
</div>
</nav>
@@ -33,28 +33,26 @@
{% if page.toc %}{% toc %}{% endif %}
{{ content }}
</article>
- {% if page.footer %}
- {% assign post_meta = site.data.post[page.slug] %}
- {% assign site_meta = site.data.meta %}
+ {% if page.post %}
<footer id="footer" class="invert plainlink">
<div class="limitwidth">
<div class="autocolumn">
<div class="column">
<span class="title">about this post</span>
<ul>
- <li>written by {% fmt_authors site.data.authors post_meta.authors %}</li>
- <li>published on {{ post_meta.date }}</li>
+ <li>written by {% fmt_authors site.data.authors page.meta.authors %}</li>
+ <li>published on {{ page.meta.date | datefmt }}</li>
</ul>
<ul>
- <li>edited {{ post_meta.edits }} times</li>
- <li>first published on {{ post_meta.date_initial }}</li>
+ <li>edited {{ page.meta.edits }} times</li>
+ <li>first published on {{ page.meta.date_initial | datefmt }}</li>
</ul>
</div>
<div class="column">
<a href="/" class="title">{{ site.domain }}</a>
<ul>
- <li>version <code>{{ site_meta.slug }}</code> (<a href="https://git.pipeframe.xyz/lonkaars/blog">git</a>)</li>
- <li>built {{ site_meta.build_date }}</li>
+ <li>version <code>{{ site.data.meta.slug }}</code> (<a href="https://git.pipeframe.xyz/lonkaars/blog">git</a>)</li>
+ <li>built {{ site.data.meta.build_date | datefmt }}</li>
</ul>
</div>
</div>
diff --git a/_plugins/datefmt.rb b/_plugins/datefmt.rb
new file mode 100644
index 0000000..7c2274f
--- /dev/null
+++ b/_plugins/datefmt.rb
@@ -0,0 +1,8 @@
+module DateFormatter
+ def datefmt(input)
+ return input.strftime("%F")
+ end
+end
+
+Liquid::Template.register_filter(DateFormatter)
+
diff --git a/_plugins/meta.rb b/_plugins/meta.rb
new file mode 100644
index 0000000..f0d420f
--- /dev/null
+++ b/_plugins/meta.rb
@@ -0,0 +1,31 @@
+module Meta
+ class Generator < Jekyll::Generator
+ def generate(site)
+ # convert yaml @0123456789 (unix timestamps) into ruby Date
+ site.data = parse_unix_dates(site.data)
+
+ for page in site.collections['items'] do
+ # directly add generated page metadata to `page.meta` in liquid
+ page.data['meta'] = site.data['post'][page.slug]
+
+ # set page.date to generated date_initial
+ page.data['date'] = page.data['meta']['date_initial']
+ end
+ end
+
+ def parse_unix_dates(data)
+ for key, value in data do
+ if value.is_a? Hash
+ data[key] = parse_unix_dates(value)
+ next
+ end
+
+ next unless value.is_a? String
+ next unless value =~ /^@\d+$/
+ data[key] = Time.at(Integer(value[1..]))
+ end
+ return data
+ end
+ end
+end
+
diff --git a/_sass/layout.scss b/_sass/layout.scss
index d699ee1..9666867 100644
--- a/_sass/layout.scss
+++ b/_sass/layout.scss
@@ -115,4 +115,3 @@ footer ul {
flex-grow: 1;
}
-
diff --git a/_sass/theme.scss b/_sass/theme.scss
index f3fd683..d599fc4 100644
--- a/_sass/theme.scss
+++ b/_sass/theme.scss
@@ -58,3 +58,38 @@ nav .right a {
font-style: italic;
}
+td, th {
+ padding: 0 1ex;
+}
+table {
+ border-color: currentColor;
+ border-spacing: 0;
+}
+
+// booktabs tables
+table th {
+ border-bottom-style: solid; // \midrule
+ padding-bottom: .4ex; // \aboverulesep
+ border-bottom-width: .05em; // \lightrulewidth
+}
+table tr:has(th) + tr td {
+ padding-top: .65ex; // \belowrulesep
+}
+table {
+ border-top-style: solid; // \toprule
+ margin-top: 0; // \abovetopsep
+ border-top-width: .08em; // \heavyrulewidth
+ padding-top: .65ex; // \belowrulesep
+
+ border-bottom-style: solid; // \bottomrule
+ padding-bottom: .4ex; // \aboverulesep
+ border-bottom-width: .08em; // \heavyrulewidth
+ margin-bottom: 0; // \belowbottomsep
+}
+
+.sortcolumn {
+ display: list-item;
+ list-style: inside;
+ list-style-type: disclosure-open;
+}
+
diff --git a/_scripts/postinfo b/_scripts/postinfo
index f31b145..efc70c2 100755
--- a/_scripts/postinfo
+++ b/_scripts/postinfo
@@ -7,15 +7,15 @@ tab="$(printf '\t')"
history="$(git log \
--follow \
--ignore-all-space --diff-filter=AM \
- --date=short --pretty=format:"%cd$tab%an" \
+ --date=unix --pretty=format:"%cd$tab%an" \
-- "$file")"
dates="$(echo "$history" | cut -d"$tab" -f1)"
authors="$(echo "$history" | cut -d"$tab" -f2 | sort -u)"
cat << EOF
-date: $(echo "$dates" | head -n1)
-date_initial: $(echo "$dates" | tail -n1)
+date: '@$(echo "$dates" | head -n1)'
+date_initial: '@$(echo "$dates" | tail -n1)'
edits: $(echo "$dates" | wc -l)
authors:
$(echo "$authors" | sed 's/^/- /')
diff --git a/_scripts/repoinfo b/_scripts/repoinfo
index b413e6e..bce0fa7 100755
--- a/_scripts/repoinfo
+++ b/_scripts/repoinfo
@@ -3,6 +3,6 @@ export LANG=C
cat << EOF
commit: $(git rev-parse HEAD)
slug: $(git describe --always --dirty='*' --abbrev)
-build_date: $(date -Idate)
+build_date: '$(date +'@%s')'
EOF
diff --git a/index.md b/index.md
index aa7f218..5ff0aa7 100644
--- a/index.md
+++ b/index.md
@@ -3,7 +3,7 @@ title: blog.pipeframe.xyz
layout: default
id: index
toc: false
-footer: false
+post: false
---
Welcome to my blog! If I ever feel like writing something there's a good chance
diff --git a/posts/by-date.md b/posts/by-date.md
new file mode 100644
index 0000000..4ddc117
--- /dev/null
+++ b/posts/by-date.md
@@ -0,0 +1,12 @@
+---
+title: Posts
+layout: default
+id: posts
+toc: false
+post: false
+---
+
+{% include posts.html
+ sort="date"
+%}
+
diff --git a/posts/by-title.md b/posts/by-title.md
new file mode 100644
index 0000000..8b0817f
--- /dev/null
+++ b/posts/by-title.md
@@ -0,0 +1,12 @@
+---
+title: Posts
+layout: default
+id: posts
+toc: false
+post: false
+---
+
+{% include posts.html
+ sort="title"
+%}
+