
<%
  const titleLink = (site?.base_uri) ? site.base_uri : '/';
  const { entriesToList = [], pageCount, pageNum, year = '' } = page;
-%>

<%- include('partials/top') %>

<body class='postMainIndex'>
  <a name="top" id="topAnchor" class="topAnchor"></a>
  <div class="page">
	  <header id="header" class="pageHeader pageSection">
		  <div class="pageHeader-titleBlock clearfix">
			  <h1 class="siteTitle"><a href="<%= titleLink %>" class="siteTitle-link"><%= site.title %></a></h1>
		  </div>

      <%- include('partials/navmain') %>

    </header>
    
    <main id="content" class="pageMain pageSection">
		  <div class="pageMain-inner">

        <%- include('partials/embed_switch') %>

        <%- include('functions') -%>

        <% if (page?.title && (page.render_opts || '').indexOf('no_title') == -1) { -%>

          <h2>
            Journal Entries By Year: 
            <a
              class="boxLink isCurrent"
              href="<%= page.path %>"
              id="<%= snakeCase(page.title) %>"
              name="<%= snakeCase(page.title) %>"
            > <%= year %></a>
          </h2>
          <% if (pageCount > 1) { -%>
            <p>
              (Page <%= pageNum %> of <%= pageCount %>)
            </p>
          <% } -%>
          <p>
            Assorted journal entries from <%= year %>.
          </p>

          <hr class="feedLine">

          <p>

        <% } -%>

        <% if (entriesToList && year) { -%>
            <% entriesToList.forEach((entry) => { -%>
              <% if (entry?.content_type === 'journal') { -%>
                <%
                  const {
                    author = {},
                    content = '',
                    date_pub = '',
                    description = '',
                    path = '',
                    readTime = '',
                    tags = [],
                    title = '',
                    tldr = ''
                  } = entry;
                -%>
                <article class="update journal h-entry js-update">

                  <div class="p-author author h-card vcard authorHidden">

                    <% if (author?.site && author?.name) { -%>

                      <% if (author?.photo) { -%>
                        <a href="<%= author.site %>"><img class="u-photo" src="<%= author.photo %>"></a>
                      <% } -%>

                      <a class="p-name fn u-url url" rel="author" href="<%= author.site %>"><%= author.name %></a>

                    <% } else if (site?.author?.site && site?.author?.name) { -%>

                      <% if (site?.author?.photo) { -%>
                        <a href="<%= site.author.site %>"><img class="u-photo" src="<%= site.author.photo %>"></a>
                      <% } -%>

                      <a class="p-name fn u-url url" rel="author" href="<%= site.author.site %>"><%= site.author.name %></a>

                    <% } -%>

                  </div>

                  <h3 id="<%= snakeCase(title) %>" >
                    <a class="p-name u-url" href="/<%= path %>"><%= title %></a>
                  </h3>

                  <% if (tldr || description) { -%>
                    <p><i>TL;DR &mdash; <%- tldr || description %></i></p>
                  <% } -%>

                  <% if (readTime) { -%>
                    <p class="journal readTime">
                      <span class="icon glasses-icon">&#x1f453;</span> <%= readTime %>
                    </p>                  
                  <% } -%>
                  
                  <% if (content) { -%>
                    <div class="e-content">
                      <%- content %>
                    </div>
                  <% } -%>

                  <footer class="update-footer clearfix">

                    <a rel="bookmark" href="/<%= path %>" class="u-url update-footer-link update-footer-time">
                      <time datetime="<%= date_pub %>"
                        class="dt-published published js-pubDate pubDate"
                        ><%= prettyDate(date_pub) %></time>
                    </a>

                    <!--
                      <span class="update-citation">[iew.us q/1g0k2]
                        <a class="u-shortlink" type="text/html" rel="shortlink" href="https://iew.us/q/1g0k2">&#128279;</a>
                      </span>
                    -->

                    <% if (Array.isArray(tags) && tags.length) { -%>

                      <div class="update-tags">
                    
                        <span class="icon folder-icon">&#x1f4c1;</span>
                    
                        <% tags.forEach((tag) => { -%>
                          <a class="boxLink" href="/journal/tags/<%= tag %>/index.html">
                            #<span class="p-category category"><%= tag %></span>
                          </a>
                        <% }) -%>
                    
                      </div>
                    
                    <% } -%>

                  </footer>

                </article>

                <p class="backLink">
                  <a class="boxLink" href="#top">Top</a>
                </p>
                <hr class="feedLine">

              <% } -%>
            <% }); -%>
          <% } -%>

          <%- include('partials/pageMenu') %>

		  </div>
	  </main>

    <%- include('partials/journal/menusub') %>
    
    <%- include('partials/bio') %>

    <%- include('partials/footer') %>

  </div>

<%- include('partials/bottom') %>
