Add last commit to posts when they changed, dim aside on posts' pages
This commit is contained in:
parent
91e2baf8d8
commit
78ac690a7c
7 changed files with 54 additions and 26 deletions
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
{% block sidebar %}
|
||||
<dl>
|
||||
<dt>Last updated on</dt>
|
||||
<dt>Published on</dt>
|
||||
<dd><time datetime="{{page.date}}">{{page.date | toISODate}}</time></dd>
|
||||
{% if commit.date and ((commit.date | toISODate) !== (page.date | toISODate)) %}
|
||||
<dt>Last updated on</dt>
|
||||
<dd><a href="https://git.arnes.space/arne/arnes.space/commit/{{commit.hash}}"><time datetime="{{commit.date}}">{{commit.date | toISODate}}</time></a></dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
|
||||
<a href="{{ "/" | url }}">← Home</a>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ h1, h2, h3, h4, h5, h6 {
|
|||
}
|
||||
|
||||
h1 {
|
||||
color: #222;
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
padding: 0 0 32px;
|
||||
|
|
@ -153,11 +154,6 @@ aside {
|
|||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
margin-left: .3em;
|
||||
}
|
||||
}
|
||||
|
||||
article {
|
||||
|
|
@ -175,18 +171,8 @@ article {
|
|||
|
||||
footer {
|
||||
grid-area: footer;
|
||||
color: #aaa;
|
||||
padding-top: 48px;
|
||||
border-top: 1px dotted #aaa;
|
||||
|
||||
a {
|
||||
color: #888;
|
||||
border-bottom: 1px dotted #888;
|
||||
|
||||
&:hover {
|
||||
background: #88888822;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// special page styling
|
||||
|
|
@ -202,11 +188,6 @@ footer {
|
|||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
a {
|
||||
// let post titles break
|
||||
display: inline;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: inside;
|
||||
padding: 0 0 0 16px;
|
||||
|
|
@ -220,3 +201,17 @@ footer {
|
|||
|
||||
article { display: none; }
|
||||
}
|
||||
|
||||
footer,
|
||||
.posts aside {
|
||||
color: #aaa;
|
||||
|
||||
a {
|
||||
color: #888;
|
||||
border-bottom: 1px dotted #888;
|
||||
|
||||
&:hover {
|
||||
background: #88888822;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
src/posts/posts.11tydata.js
Normal file
30
src/posts/posts.11tydata.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
const { promisify } = require('util')
|
||||
const exec = promisify(require('child_process').exec)
|
||||
|
||||
const commitFromLog = message => {
|
||||
if (message === '') return {}
|
||||
|
||||
const [ commit, author, date, _, msg ] = message.split('\n')
|
||||
|
||||
return {
|
||||
hash: commit.replace(/^commit /, ''),
|
||||
author: author.replace(/^Author:\s*/, ''),
|
||||
date: new Date(date.replace(/^Date:\s*/, '')),
|
||||
message: msg.trim()
|
||||
}
|
||||
}
|
||||
|
||||
const lastCommitFor = async file => {
|
||||
const { stdout } = await exec(`git log -n 1 --pretty=medium --date=iso -- ${file}`)
|
||||
return commitFromLog(stdout)
|
||||
}
|
||||
|
||||
module.exports = async (_) => {
|
||||
return {
|
||||
tags: "posts",
|
||||
layout: "posts.njk",
|
||||
eleventyComputed: {
|
||||
commit: async data => await lastCommitFor(data.page.inputPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"tags": "posts",
|
||||
"layout": "posts.njk"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue