Automating my 'coffee warning' on long article
While writing my 2 next very long posts (should be published soon), I had a fun and stupid idea: I have the tendency to alert at the start of a long blog post to tell the reader to maybe go get a coffee before starting reading… I have done this many time and while I started typing some similar intro in that next post, I decided to automate it as a good lazy person :).
It looks like this in dark mode:

Figure 1: Screenshot in dark mode of a post showing a warning saying: “This post is tagged as a long post, meaning it may be better to prepare yourself a coffee or a drink of your choice before starting reading this page :).”
And in light mode:

Figure 2: Screenshot in light mode of a post showing a warning saying: “This post is tagged as a long post, meaning it may be better to prepare yourself a coffee or a drink of your choice before starting reading this page :).”
Similar to what I’ve done with the old post warning, I edited the MinIndie theme to include a new article-precontent.html partial just above the entry content and then created a custom article-precontent.html partial (see below it’s content).
In the single.html file of the theme, I’ve added above the content itself:
{{- with .Site.Params.tagPostOlderThanXDays -}}
{{- end -}}
{{- partial "article-precontent.html" . -}}
The default article-precontent.html partial is empty.
My custom article-precontent.html partial is very similar to the old post one:
{{- with .Params.Coffee -}}
<br />
<div class="alert">
<strong>Nota</strong>: This post is tagged as a long post, meaning it may be better to prepare yourself a coffee or a drink of your choice before starting reading this page :).
</div>
{{- end -}}
This will be displayed each time a post has Coffee = 1 in the frontmatter section, for example for the article IndieWeb adventure: First steps:
+++
title = "IndieWeb adventure: First steps"
author = ["Bacardi55"]
date = 2024-01-29
tags = ["indieweb", "indienews", "blog"]
draft = false
indienews = 1
coffee = 1
+++
The update to the theme has also be pushed to sourcehut.
Now I don’t have to manually type a sentence to tell my reader to get a drink at the start of long post… A very useless thing to add to this blog, but that made me smile a little, so that’s a win :). I didn’t edited any other post than the indieweb one to avoid raising old posts in rss readers, but going to use it now!