Skip to main content

Pretty Good Hat

Recent chat around micro.blog about enabling an “on this day” plugin prompted me to put together the shortcode below. Unlike sophisticated hugo configurations, mine is just updated by a cron job, so I can render it statically, without any javascript, and it’s always current to the day, even if I haven’t posted that day.

I call this shortcode from my /now page:

Posts on this day ({{ now.Format "Jan 2" }}):
<ul>
{{ range (where .Site.RegularPages "Section" "in" (slice "post" "note")) }}
  {{ if eq .Date.YearDay now.YearDay}}
  <li><a href="{{ .Permalink }}">{{ .Date.Format "2006-01-02"}} / {{ .Title }}</a>
  {{end}}
{{ else }}
    <li>... no entries ... 
{{ end }}
</ul>

A shadowed road leading ahead around a corner, and overlooking a high mountain valley covered in snow, lit with low sun

Yesterday was a good, busy day. I ran early errands and enjoyed, as always, the view coming over the divide into the valley. Today? It’s back to work.

Hugo: render hooks and partial for displaying images

Markdown render hooks allow for adding customization to the default markdown to html rendering in hugo. When placed in _default/_markup/render-image.html, this example overrides the standard rendering of images from markdown to include a call to Glightbox.

    <a href="{{ .Destination | safeURL }}" class="glightbox" data-gallery="{{ .Page.Permalink }}">
    <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" style="max-height: 720px" />
    </a>

This grabs the page’s permalink for the data-gallery property.

For photos specified in a post’s yaml frontmatter, I call a partial in my article template, photos.html:

    {{ range .Params.photo }}  
    <a href="{{ replace .value " " "" }}" class="glightbox" 
            data-gallery="{{ replace .value " " "" }}">
    <img src="{{ replace .value " " "" }}" alt="{{ .alt }} "
    style="max-height: 720px;"  />
    </a>
    {{ end }}

Both of these assign the data-gallery property in order to avoid overlapping galleries on index or other pages with multiple posts. One future improvement to try is building a shortcode to replace the partial, so that the gallery ID or other properties can be customized at call time.

Inspired by Jessica Smith I did some learning today and added glightbox to improve the way I display photos. Way back in a pre-history iteration of the site, I had lightview working here with some complex templating (which I think was generated by a shell script that I wrote as part of a Lightroom export plugin!) that I never quite rebuilt for the new design a few years ago, so it’s super nice to have this back again. Thanks to Jessica’s prompting and critical help identifying my error in implementing it, it works! Next up is probably cobbling together a hugo shortcode so that I have a little more flexibility in layout and gallery options. I should probably also just write down how this works so I don’t have to figure it out again next time.

What circle of hell is it to be waiting thirty minutes for your zoom HOA meeting to start?

A steep snowy ridge lit by sunrise, with pink and orange clouds against the blue sky and windows reflecting bright light

Today we go back to work and school after a long winter’s holiday. I’m not particularly ready, but am resolved to work on some elements of focus and persistence to keep myself and my team getting done what needs doing.