πŸš§πŸ—οΈπŸ‘·πŸΎNote: This site is under construction. Expect a lot of broken links and layouts. Have feedback? Email me at [email protected]

Home β†’ The Bikeshed β†’ Components

updates.html

Published:

This partial renders any updates specified in the post’s metadata in the main content sorted in reverse chronological order. I would have liked it in the body instead but then I couldn’t access it as metadata.

In the post’s frontmatter, you define an updates object containing an array of objects with the keys date and note:

updates:
    - date: ...
      notes: ...
    - date: ...
      notes: ...    

This creates a <section> element with an id of updates and an <h2> heading of Updates.

Source Code

<section id="updates">
    <h2>Updates</h2>
    <ul>
    {{ range (sort .Params.updates "date" "desc") -}}
        <li>
            <b><time datetime="{{ dateFormat `2006-01-02T15:04:05-07:00` .date }}">{{ dateFormat `02 Jan 2006 at 15:04 MST` .date }}</time></b>
            <div>
                {{ $.RenderString .notes }}
            </div>
        </li>
    {{- end }}
    </ul>
</section>
<hr>