<aside class="asideContent asideRight asideLinkMenu asideMenu linkMenu">
    <h4 class="asideMenu-title">
      <a href="/journal/" class="asideMenu-title-link <%=page.name === 'index' ? 'isCurrent' : ''%>">Journal Entries</a>
    </h4>

    <h5 class="asideMenu-subtitle">By Year</h5>
    <ul class="asideMenu-list">
      <%
        if (site?.pages) {
          let
            years = [];
          site.pages.forEach(function(page) {
            if (page.content_type && page.content_type === 'journal' && page.date_pub) {
              let the_year = (new Date(page.date_pub)).getFullYear();
              if (years.indexOf(the_year) === -1) {
                years.push(the_year);
              }
            }
          });
          years = years.sort().reverse();
          years.forEach((year) => {
            -%>
              <li class="asideMenu-item">
                <a class="asideMenu-link <%= page.path.indexOf(year) > -1 ? 'isCurrent' : '' %>"
                    href="/journal/<%= year %>/index.html">
                  <%= year %>
                </a>
              </li>

            <%
          })
        }
      -%>
    </ul>

    <h5 class="asideMenu-subtitle">By Tags</h5>
    <ul class="asideMenu-list">
      <%
        if (Array.isArray(site?.tags)) {
          site.tags.forEach((tag) => {
            -%>
              <li class="asideMenu-item">
                <a class="asideMenu-link <%= page.path.includes('/' + tag + '/') ? 'isCurrent' : '' %>"
                    href="/journal/tags/<%= tag %>/index.html">
                  #<%= tag %>
                </a>
              </li>

            <%
          })
        }
        else {
          -%>
          <%= JSON.stringify(site.tags, null, 2) -%>
          <%
        }
      -%>

    </ul>
</aside>