
{% macro tags_url(name, url, class) %}
  {%- set page_url = request_context_get('url') -%}

  <a class="{{class}}"

     {% if url.is_prev_to(page_url) %}rel="prev"{% endif %}
     {% if url.is_next_to(page_url) %}rel="next"{% endif %}

     href="{{url.url()}}">
    {{name}}
  </a>
{% endmacro %}


{# TODO: autodetect relations? #}
{% macro page_anchor(page, short=false, classes=(), anchor_title="", rel="") %}
  {% set storage = get_storage() %}
  {% set article = storage.get_article(page.article_id) %}

  <a href="{{root_url(page.language).to_post(article.slug).url()}}"
     {% if classes %}class="{{' '.join(classes)}}"{% endif %}
     {% if anchor_title %}title="{{anchor_title}}"{% endif %}
     {% if rel %}rel="{{rel}}"{% endif %}
     >
    {{page_title(page, short=short)}}
  </a>
{% endmacro %}
