feat(tazjin/blog): Add distinction between published & updated times
Fixes a long-standing todo by adding an additional field for the time at which a post was updated, and handling this in both site generation (to note the update date after the publish date) and in Atom feed generation (by populating both the updated and published fields). Change-Id: If80db43459b2a0c77eea4dde7255651b5d6cd64b Reviewed-on: https://cl.tvl.fyi/c/depot/+/2766 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
817cd6f166
commit
4450003bd7
4 changed files with 13 additions and 1 deletions
|
@ -111,6 +111,10 @@ let
|
|||
${elem "title" e.title}
|
||||
${elem "id" e.id}
|
||||
${elem "updated" (renderEpoch e.updated)}
|
||||
${if e ? published
|
||||
then elem "published" (renderEpoch e.published)
|
||||
else ""
|
||||
}
|
||||
${if e ? content
|
||||
then ''<content type="html">${escape e.content}</content>''
|
||||
else ""
|
||||
|
|
|
@ -15,6 +15,9 @@ let
|
|||
title = string;
|
||||
date = int;
|
||||
|
||||
# Optional time at which this post was last updated.
|
||||
updated = option int;
|
||||
|
||||
# Path to the Markdown file containing the post content.
|
||||
content = path;
|
||||
|
||||
|
|
|
@ -74,6 +74,11 @@ let
|
|||
echo '<article><h2 class="inline">${escape post.title}</h2>' >> $out
|
||||
echo '<aside class="date">' >> $out
|
||||
date --date="@${toString post.date}" '+%Y-%m-%d' >> $out
|
||||
${
|
||||
if post ? updated
|
||||
then ''date --date="@${toString post.updated}" '+ (updated %Y-%m-%d)' >> $out''
|
||||
else ""
|
||||
}
|
||||
echo '</aside>' >> $out
|
||||
|
||||
${
|
||||
|
|
|
@ -14,7 +14,7 @@ let
|
|||
title = post.title;
|
||||
content = readFile (renderMarkdown post.content);
|
||||
published = post.date;
|
||||
updated = post.date; # TODO(tazjin): this should be distinct from published
|
||||
updated = post.updated or post.date;
|
||||
|
||||
links = singleton {
|
||||
rel = "alternate";
|
||||
|
|
Loading…
Reference in a new issue