{% extends '../layout.twig' %}

{% block body %}
  <article class="page" data-module="page">
    <header class="page__header">
      <div class="page__header-nav">
        <a href="/" class="page__header-nav-item">
          Documentation
        </a>
        {{ svg('arrow-right') }}
        {% if page._parent %}
          <a class="page__header-nav-item"
            {% if pageParent.uri %}
              href="/{{ pageParent.uri }}"
            {% else %}
              href="/page/{{ pageParent._id }}"
            {% endif %}>
            {{ pageParent.title }}
          </a>
        {% endif %}
      </div>
      <time class="page__header-time">
        Last edit {{ (page.body.time / 1000)  | date("M d Y") }}
      </time>
      {% if isAuthorized == true %}
        {% include 'components/button.twig' with {label: 'Edit', icon: 'pencil', size: 'small', url: '/page/edit/' ~ page._id, class: 'page__header-button'} %}
      {% endif %}
    </header>
    <h1 class="page__title">
      {{ page.title }}
    </h1>
    {% if (config.carbon and config.carbon.placement and config.carbon.serve) %}
      <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve={{ config.carbon.serve }}&placement={{ config.carbon.placement }}" id="_carbonads_js"></script>
    {% endif %}
    <section class="page__content">
      {% for block in page.body.blocks %}
        {# Skip first header, because it is already showed as a Title #}
        {% if not (loop.first and block.type == 'header') %}
          {% if block.type in ['paragraph', 'header', 'image', 'code', 'list', 'delimiter', 'table', 'warning', 'checklist', 'linkTool', 'raw', 'embed'] %}
            <div class="page__content-block">
              {% include './blocks/' ~ block.type ~ '.twig' with block.data %}
            </div>
          {% endif %}
        {% endif %}
      {%  endfor %}
    </section>
    {% include '../components/navigator.twig' with {previousPage:  previousPage, nextPage: nextPage} %}
  </article>

{% endblock %}
