{% extends "base.html" %}

{% block seo %}
    {{ super()}}
    {%- if author is defined -%}
    {% include "json_ld_author.html" ignore missing%}
    {%- else -%}
    {% include "json_ld_index.html" ignore missing%}
    {%- endif -%}
{% endblock %}

{% block main %}

{%if title and current_page != "index.html" and author is not defined %}
<div class="list-title">
    <article><strong> {{ title }} </strong></article>
</div>
{% endif %}

{% if current_page == "index.html" %}
    
    {% if site.banner_image %}
    <div class="content-banner-image index-banner-image" style="background-image: url({{site.banner_image}});"></div>
    {% endif %}

    {% if hero is defined %}
    <div class="hero">
        <article>
            {{hero}}
        </article>
    </div>
    {% endif %}

{% endif %}

{% if author is defined %}
<div class="hero author-hero">
    <article class="h-card">
        <div class="author-hero-profile">
            <div class="author-hero-flex">
                <div class="author-hero-image">
                    <img src="{{url_for(path=author.avatar)}}" alt="{{ author.name }}" class="avatar u-photo">
                </div>
                <div class="author-hero-info">
                    <h1 class="p-name">{{author.name}}</h1>
                    <div class="author-hero-bio">
                        <p class="p-note">{{author.bio}}</p>
                    </div>
                </div>
            </div>
            {% if author.links %}
            <div class="author-hero-links">
                <ul>
                    {% for link in author.links %}
                    <li><a href="{{ url_for(path=link.1) }}" {% if link.1 is starting_with("http") %}target="_blank"{% endif %} class="u-url">{{link.0}}</a></li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}
        </div>
    </article>
</div>
{% endif %}
<div class="content-list {%if sidebar is defined %}content-list-with-sidebar{% endif %} h-feed">
    {% if title %}<h1 class="p-name" style="display: none;">{{ title }}</h1>{% endif %}
    <div class="left">
    {%- for content in content_list %}
    <article class="content-list-item h-entry">
        <h2 class="p-name" style="display: none;">{{ content.title }}</h2>
        <a class="u-url" href="{{url_for(path=content.slug ~ '.html')}}" style="display: none;"></a>
        {% if content.date %}<time class="dt-published" datetime="{{ content.date | date(format='%+') }}" style="display: none;">{{ content.date | default_date_format }}</time>{% endif %}
        
        <div class="content-title-wrapper">
            <h2 class="content-title"><a href="{{url_for(path=content.slug ~ '.html')}}">{{ content.title }}</a></h2>
            {%if content.pinned %}<span class="content-pin">&star;</span>{%endif%} 
        </div>
        <p class="content-excerpt p-summary">
            {% if content.description %}
            {{ content.description | replace(from='"', to="") | truncate(length=250, end=" ...") }}
            {% else %}
            {{ content.html | striptags | trim_start_matches(pat=content.title) | truncate(length=250, end=" ...") }}
            {%- endif %}
            <a class="secondary" href="{{url_for(path=content.slug ~ '.html')}}">read more &rarr;</a>
        </p>
        {% if content.date -%}
        <footer class="data-tags-footer">
            <span class="content-date"><a class="secondary" href="{{url_for(path=content.slug ~ '.html')}}">{{ content.date | default_date_format }}</a></span>
            {% if content.tags -%}
            <ul class="content-tags overflow-auto">
                {% for tag in content.tags | slice(end=3) -%}
                {% set slug = "tag-" ~ tag | trim | slugify %}
                {% set link = slug ~ ".html"%}
                <li><a href="{{url_for(path=link)}}" class="p-category">{{ tag }}</a></li>
                {%- endfor %}
            </ul>
            {%- endif %}
        </footer>
        {%- endif %}
    </article>
    {%- else -%}
    <article class="content-list-item left">
        <h2 class="content-title">No content found</h2>
        <p class="content-excerpt">
            Add some markdown content and generate the site. &rarr; <a target="_blank" href="https://marmite.blog/getting-started.html">Getting Started</a>
        </p>
    </article>
    {%- endfor %}
    {% if total_pages is defined and total_pages > 1 %}
    {% include "pagination.html" ignore missing %}
    {% endif %}
    </div>
    {%- if sidebar is defined %}
    <div class="right">
        <article>{{sidebar}}</article>
    </div>
    {%- endif %}
</div>
{% endblock %}