Part 32: Project Pages and loops

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 32

Projects Page

I realized that at some point I'm going to have too many projects to fit on the home page, so I need to limit the number that show up and set up a page to list the overall projects.

I want it to sit at /projects so I'll create a MD file to handle that and a template to handle this specific page type.

---
layout: project-list
pagination:
data: projects
size: 1
alias: project
permalink: "projects/"
eleventyComputed:
title: "Project List"
description: "A list of projects that Aram Zucker-Scharff has documented working on."
---

I'll start with the project page as the template. Then I can take the loop through the projects object from the front page.

{% raw %}

				{% for project in projects %}
<li class="capitalize-first">
<a href="{{project.url}}">{{project.title}}</a> | <span>Days worked: {{project.count}}</span> | <span>Status: {{project.complete}}</span> <!-- last updated: {{project.lastUpdatedPost}} -->
</li>
{% endfor %}

{% endraw %}

Ok this is good. To make this easy to debug I should put the link on the front page. So to do that I need to do two things, break the project for loop, and add a link to the new projects page.

Hmm, it doesn't look like there is actually a break in Nunjucks. Perhaps I should try altering the array?

Can I use an if check like if loop.index < 6 in the for statement? No that doesn't work. Looks like the if check is only for properties of the looped object.

Ah, no, that's not it at all. That doesn't work. Ah, ok, the best thing to do here is to slice the array before looping it. Instead of a break for this situation, we use slice.

for project in projects | slice(5)

Yup, that worked!

And I'll remove the dots on the li elements.

    #all-projects
li
list-style: none

Ok, did a little touching up of the formatting, and now we've got that page. Good to go.

Preview Images on Lists

Ok, next thing I wanted to check off is including the image on some of the post preview pages. Let's start with the tag pages.

First I'll set up a stand-alone Sass file for the post preview component. Then I'll add a containing class to the post-summary component itself.

Then I'm going to pull the post image HTML out of post.njk and into its own file in the partials folder. This way I can reuse the basic HTML structure of the image across the site.

Ok, had to make sure my styles are in place but it looks good. I may want to modify the styles a little bit, it isn't perfect and I may want to play with it a bit.

Now I want to add it to the front page as well. But I'll save that until the next day of working on this project.

git commit -am "Finishing off day 32"