<%- include('../../functions') -%>
<%
  var
    journals = site.pages.filter(thePage => thePage.content_type === 'journal'),
    curr = journals.filter(journal => journal.filePath === page.filePath),
    currIndex = journals.map(journal => journal.filePath).indexOf(page.filePath),
    prev = currIndex < (journals.length - 1) ? journals[currIndex + 1] : null,
    next = currIndex > 0 ? journals[currIndex - 1] : null;
%>

<% if (page.title) { -%>

  <h2>
    <a class="p-name u-url" href="/<%= page.path %>"><%= page.title %></a>
  </h2>

<% } -%>

<% if (page.readTime) { -%>

  <p class="journal readTime">
    <span class="icon glasses-icon">&#x1f453;</span> <%= page.readTime %>
  </p>

<% } -%>


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

<div class="e-content">
  <%- content %>
</div>

<footer class="update-footer clearfix">

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

  <div class="update-tags">

    <span class="icon folder-icon">&#x1f4c1;</span>

    <% page.tags.forEach((tag, index) => { -%>
      <%= index > 0 ? ' / ' : '' %>
      <a href="/journal/tags/<%= tag %>/index.html">
        #<span class="p-category category"><%= tag %></span>
      </a>
    <% }) -%>

  </div>

  <% } -%>

  <!--
    <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>
  -->

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

  <div class="update-nav clearfix">

    <% if (prev) { -%>

      <div class="update-nav-linkWrapper">
        &lt; Previous Entry
        <a class="update-nav-link update-nav-prev" href='/<%= prev.path %>'>
          <%=prev.title%>
          <br />
          <span class="update-nav-pubDate">
            (<time
              datetime="<%= prev.date_pub %>"
              class="dt-published published js-pubDate pubDate js-noRelativeTime"
              ><%= shortDate(prev.date_pub) %></time>)
          </span>
        </a>  
      </div>
      
    <% } -%>
  
    <% if (next) { -%>
  
      <div class="update-nav-linkWrapper update-nav-nextWrapper">
        Next Entry &gt;
        <a class="update-nav-link update-nav-next" href='/<%= next.path %>'>
          <%=next.title%>
          <br />
          <span class="update-nav-pubDate">
            (<time
                datetime="<%= next.date_pub %>"
                class="dt-published published js-pubDate pubDate js-noRelativeTime"
                ><%= shortDate(next.date_pub) %></time>)
          </span>
        </a>  
      </div>
    
    <% } -%>
  
  </div>


</footer>