<% var blogData = [{link:"being-a-present-father.html",date:1616959846297},{link:"jiu-jitsu-chokes-and-strangulations---my-favorite-ways-to-safely-submit-someone.html",date:1606690800000},{link:"how-i-usually-learn-new-tech.html",date:1616959846317},{link:"how-i-made-this-blog.html",date:1605826800000},{link:"introduction-to-this-website-and-blog.html",date:1605049200000},{link:"practicing-stoicism.html",date:1616959846344},{link:"how-i-stay-sharp-and-motivated-to-keep-learning.html",date:1616959846354}] %>


<% var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
<% var years = Array.from( new Set(blogData.map( function(blogDataObject) { return new Date(blogDataObject.date).getFullYear()}))) %>

<% include ../components/head %>
<% include ../components/header %>
<main>

    <section class="container--writing">
        <h1>The Brain Dump</h1>
        <% years.forEach( function(year) { %>
        <p class="year">
            <%= year %>
        </p>
        <ul>
            <% blogData.sort( function(a,b) {return (b.date-a.date)}).forEach( function(blogFile) { %>
            <% if( year === (new Date(blogFile.date).getFullYear())) { %>

            <li>
                <p><%= new Date(blogFile.date).getDate() %> <%= months[new Date(blogFile.date).getMonth()] %> ->
                </p>
                <a
                    href="<%= blogFile.link %>"><%=blogFile.link.split('.')[0].split('-').map(function(word){ if (word[0] === undefined) { return "-" + word.slice(1)} return word[0].toUpperCase() + word.slice(1)}).join(' ') %></a>
            </li>
            <% } %>
            <% }) %>
        </ul>
        <% }) %>
    </section>

</main>
<% include ../components/footer %>

</html>