Part 28: Featured Images

More devblog
Close up photo of keyboard keys.
| 'TYPE' by SarahDeer is licensed with CC BY 2.0 |

Project Scope and ToDos

  1. Static Site Generator that can build the blog and let me host it on Github Pages
  2. I want to write posts in Markdown because I'm lazy, it's easy, and it is how I take notes now.
  3. I don't want to spend a ton of time doing design work. I'm doing complicated designs for other projects, so I want to pull a theme I like that I can rely on someone else to keep up.
  4. Once it gets going, I want template changes to be easy.
  5. It should be as easy as Jekyll, so I need to be able to build it using GitHub Actions, where I can just commit a template change or Markdown file and away it goes. If I can't figure this out than fk it, just use Jekyll.
  6. I require it to be used by a significant percent of my professional peers so I can get easy answers when something goes wrong.
  7. I want source maps. This is a dev log site which means whatever I do with it should be easy for other developers to read.
  • Can I use the template inside of dinky that already exists instead of copy/pasting it?
  • Is there a way to have permalinks to posts contain metadata without organizing them into subfolders?
  • How do I cachebreak files on the basis of new build events? Datetime? site.github.build_revision is how Jekyll accomplishes this, but is there a way to push that into the build process for Eleventy?

  • Make link text look less shitty. It looks like it is a whole, lighter, font.

  • Code blocks do not have good syntax highlighting. I want good syntax highlighting.

  • Build a Markdown-it plugin to take my typing shortcuts [prob, b/c, ...?] and expand them on build.

  • See if we can start Markdown's interpretation of H tags to start at 2, since H1 is always pulled from the page title metadata. If it isn't easy, I just have to change my pattern of writing in the MD documents.

  • Should I explore some shortcodes?

  • Order projects listing by last posted blog in that project

  • Limit the output of home page post lists to a specific number of posts

  • Show the latest post below the site intro on the homepage.

  • Tags pages with Pagination

  • Posts should be able to support a preview header image that can also be shown on post lists.

  • Create a Markdown-It plugin that reads the project's repo URL off the folder data file and renders commit messages with links to the referenced commit. (Is this even possible?) (Is there a way to do it with eleventy instead?)

  • Create Next Day/Previous Day links on each post / Next/Previous post on post templates from projects

  • Tags should be in the sidebar of articles and link to tag pages

  • Create a skiplink for the todo section (or would this be better served with the ToC plugin?) - Yes it would be!

  • Add a Things I Learned section to the project pages that are the things I learned from that specific project.

  • Add a technical reading log to the homepage

  • Hide empty sections.

  • Add byline to post pages

  • Have table of contents attach to sidebar bottom on mobile

  • Support dark mode

  • Social Icons

  • SEO/Social/JSON-LD HEAD data

Day 28

Ok, we're blocked from finishing the various social and search tags by the lack of feature images in the blog. So that's next.

So I want to have intellegent defaults here as well. I can have defaults at the project level, the site level and the individual post level. For the Devblog project I'll add to the devblog.json file "featuredImage": "radial_crosshair.jpg". All my images will be in ../img/ so to keep it DRY let's leave that out of the filepaths.

I'll set the same property at the site level, taking my default image from my GitHub blog.

Ok, for the individual blog posts I guess I'll need a little more detail. Since I'll often be taking photos from Creative Commons I need to have a place to put credit. Ok, so I've got a few things to add to the YAML metadata.

featuredImage: "close-up-keys.jpg"
featuredImageCredit: "'TYPE' by SarahDeer is licensed with CC BY 2.0"
featuredImageLink: "https://www.flickr.com/photos/40393390@N00/2386752252"
featuredImageAlt: "Close up photo of keys."

I can add the following block to my social-header.njk file now:

{% raw %}

{% if featuredImage %}

<meta property="og:image" content="{{site.site_url}}/img/{{featuredImage}}" />
<meta name="twitter:image" content="{{site.site_url}}/img/{{featuredImage}}" />

{% endif %}

{% endraw %}

git commit -am "Day 28 half way done."

In my Jekyll site I had to code a page-level value with a site-level fallback. 11ty's deep data merge process allows me to just rely on the cascade of settings and JSON files to properly select a default.

Ok, that's the social tags! I'll set an else condition to make sure that there is always an og:type (default to content="website") and we're good to go.

Oh, I want to add the post image to the template too, but only when it is one set at the post level. Being a good web citizen, I should always have alt text on my image, so I'm going to only include it in the post template when I have alt text, that's an easy way to assure not every post has the default image.

I dunno what the right tag is for this? Sometimes I use aside but I think I'm supposed to use figure right? I'll use that here.

{% raw %}

    {% if featuredImageAlt %}
<figure class="figure preview-image">
<img src="{{site.site_url}}/img/{{featuredImage}}" alt="{{featuredImageAlt}}">
{% if featuredImageCaption or featuredImageCredit %}
<figcaption class="figcaption">
{% if featuredImageCaption %}{{featuredImageCaption}}{% endif %}{% if featuredImageCredit %} | <em><a href="{{ featuredImageLink }}" target="_blank">{{featuredImageCredit}}</a></em> | {% endif %}
</figcaption>
{% endif %}
</figure>
{% endif %}

{% endraw %}

Ok, basic image stuff works!

git commit -am "Last commit from day 28"