{% load fullurl wagtailimages_tags mep_tags %}
{% comment %}
Add HTML metadata tags for unfurling, twitter preview, etc.
Uses wagtail page fields if available; uses meta_page_title,
page_description, and page_meta_image if set in context.
{% endcomment %}
{% firstof page.seo_title page.title page_title as meta_page_title %}
{% firstof page.get_plaintext_description page.search_description page_description as meta_description %}
{# keywords for meta not yet implemented in wagtail #}
{# #}
{% if meta_description %}
{% endif %}
{# include citation information for tools like Zotero #}
{% if request %} {# include full url when available #}
{% endif %}
{% if page.homepage %} {# project citation on home page #}
{% elif page.contentpage or page.essaypage %} {# content/essay page citation details #}
{% for author_block in page.authors %}
{% endfor %}
{% endif %}
{# open graph metadata #}
{% if meta_page_title %}
{% endif %}
{% if meta_description %}
{% endif %}
{# twitter card #}
{% if meta_page_title %}
{% endif %}
{% if meta_description %}
{% endif %}
{# add if/when S&co project has a twitter account#}
{% if request %} {# full urls required for image, dependent on request in context #}
{% with default_image="img/social.png" %}
{% if page.contentpage.featured_image %}
{% image page.contentpage.featured_image max-1080x1080 as featured_image %}
{% elif page.essaypage.featured_image %}
{% image page.essaypage.featured_image max-1080x1080 as featured_image %}
{% elif page.landingpage.header_image %}
{% image page.landingpage.header_image max-1080x1080 as featured_image %}
{% endif %}
{% if featured_image %}
{# using fullurl twice because it doesn't support capturing result #}
{% elif page_iiif_image %} {# IIIF image for preview #}
{% with page_iiif_image|iiif_image:"size:width=1080" as image %}
{% endwith %}
{% else %}
{% endif %}
{% endwith %}
{% for author_block in page.authors %}{% if author_block.value.twitter_id %}
{% endif %}{% endfor %}
{% endif %}