{% extends 'base.html.twig' %}

{% block content %}
    <section class="h-feed">
        <h1 class="p-name">Joe Carstairs' notes</h1>

        <p hidden>
             These links are collected by
            <a class="p-author h-card" href="{{ url('index') }}">
                Joe Carstairs
            </a>.
        </p>
        <p hidden>
             <a class="u-url" href="{{ url('notes') }}">Permalink</a>
        </p>

        {% if years %}
            <nav class="skip-to">
                Skip to:
                <ul>
                    {% for year in years %}
                        <li><a href="#{{ year }}">{{ year }}</a></li>
                    {% endfor %}
                </ul>
            </nav>
        {% endif %}

        {% for year in years %}
            <h2 id="{{ year }}">{{ year }}</h2>

            <nav class="skip-to">
                Skip to:
                <ul>
                    {% for month in months[year] %}
                        <li><a href="#{{ year }}-{{ month }}">
                            {{ monthNames[month] }} <span class="visually-hidden">{{ year }}</span>
                        </a></li>
                    {% endfor %}
                </ul>
            </nav>

            {% for month in months[year] %}
                <h3 id="{{ year }}-{{ month }}">{{ monthNames[month] }}</h3>

                {% for note in notes[year][month] %}
                    <section class="h-entry">
                        <a class="u-url" href="{{ url('note', { slug: note.slug }) }}">
                            <h4 class="p-name">
                                Note {{ note.slug }}
                            </h4>
                            <p>
                                Added:
                                <time class="dt-published" datetime="{{ note.publishedDate.format('c') }}">
                                    {{ note.publishedDate.format('j F Y') }}
                                </time>
                            </p>

                            <section class="e-content">
                                {% apply markdown_to_html %}
                                    {{ note.content|markdown_to_html|striptags('<i><em><b><strong><sup><p>')|html_to_markdown }}
                                {% endapply %}
                            </section>
                        </a>
                    </section>
                {% endfor %}
            {% endfor %}
        {% else %}
            <p>I have no notes.</p>
        {% endfor %}
    </section>
{% endblock %}
