diff --git a/.eleventy.js b/.eleventy.js index 07a08ef..0cc9ac0 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -9,7 +9,6 @@ module.exports = function (config) { config.addPassthroughCopy("src/assets/ibm-plex/IBM-Plex-Mono/fonts/**/*") // template filters - config.addFilter('toJSON', obj => JSON.stringify(obj)) config.addFilter('toISODate', date => DateTime.fromJSDate(date).toISODate()) config.addFilter('header', header) diff --git a/package.json b/package.json index 2f2fca6..b00abf9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "devDependencies": { "@11ty/eleventy": "^1.0.0", "@thi.ng/hiccup": "3.6.22", + "glob": "^7.2.0", "lodash": "^4.17.21", "luxon": "^2.3.0", "seedrandom": "^3.0.5" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5405665..19fae40 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,6 +3,7 @@ lockfileVersion: 5.3 specifiers: '@11ty/eleventy': ^1.0.0 '@thi.ng/hiccup': 3.6.22 + glob: ^7.2.0 lodash: ^4.17.21 luxon: ^2.3.0 seedrandom: ^3.0.5 @@ -10,6 +11,7 @@ specifiers: devDependencies: '@11ty/eleventy': 1.0.0 '@thi.ng/hiccup': 3.6.22 + glob: 7.2.0 lodash: 4.17.21 luxon: 2.3.0 seedrandom: 3.0.5 diff --git a/src/_includes/posts.njk b/src/_includes/posts.njk index c5abbcc..111dd9a 100644 --- a/src/_includes/posts.njk +++ b/src/_includes/posts.njk @@ -2,8 +2,13 @@ {% block sidebar %}
-
Last updated on
+
Published on
+{% if commit.date and ((commit.date | toISODate) !== (page.date | toISODate)) %} +
Last updated on
+
+{% endif %}
+ ← Home {% endblock %} diff --git a/src/assets/style.scss b/src/assets/style.scss index 10be6fd..1738607 100644 --- a/src/assets/style.scss +++ b/src/assets/style.scss @@ -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; + } + } +} diff --git a/src/posts/posts.11tydata.js b/src/posts/posts.11tydata.js new file mode 100644 index 0000000..1cab9c2 --- /dev/null +++ b/src/posts/posts.11tydata.js @@ -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) + } + } +} diff --git a/src/posts/posts.json b/src/posts/posts.json deleted file mode 100644 index 4b10539..0000000 --- a/src/posts/posts.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "tags": "posts", - "layout": "posts.njk" -}