attila_pelican_theme/templates/partials/og_article.html

74 lines
3 KiB
HTML

{# <!-- Choosing locale --> #}
{% if OG_LOCALE %}
{% set default_locale = OG_LOCALE %}
{% else %}
{% set default_locale = 'en_US' %}
{% endif %}
{# <!-- Choosing cover image --> #}
{% if article.og_image %}
{% if article.og_image|lower|truncate(4, True, '') == "http" %}
{% set default_cover = article.og_image %}
{% else %}
{% set default_cover = SITEURL+"/"+article.og_image %}
{% endif %}
{% elif article.cover %}
{% if article.cover|lower|truncate(4, True, '') == "http" %}
{% set default_cover = article.cover %}
{% else %}
{% set default_cover = SITEURL+"/"+article.cover %}
{% endif %}
{% elif HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% else %}
{% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/post-bg.jpg" %}
{% endif %}
{# <!-- Choosing description --> #}
{% if article.headline %}
{% set description = article.headline %}
{% elif article.summary %}
{% set description = article.summary|striptags|truncate(140) %}
{% endif %}
<!-- Open Graph -->
{% for admin in FACEBOOK_ADMINS %}
<meta property="fb:admins" content="{{ admin }}" />
{% endfor %}
<meta property="og:site_name" content="{{ SITENAME }}"/>
<meta property="og:title" content="{{ article.title|striptags }}"/>
<meta property="og:description" content="{{ description }}"/>
<meta property="og:locale" content="{{ article.metadata.get('og_locale', default_locale) }}"/>
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="{{ article.date }}"/>
<meta property="article:modified_time" content="{{ article.modified }}"/>
<meta property="article:author" content="{{ SITEURL }}/{{ article.author.url }}">
{% for name,link in SOCIAL if name.lower() in ['facebook'] %}
<meta property="article:publisher" content="{{ link }}" />
{% endfor %}
<meta property="article:section" content="{{ article.category.name }}"/>
{% for tag in article.tags %}
<meta property="article:tag" content="{{ tag.name }}"/>
{% endfor %}
<meta property="og:image" content="{{ default_cover }}">
<!-- Twitter Card -->
{% for name,link in SOCIAL if name.lower() in ['twitter'] %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ link|replace('http://', 'https://')|replace('https://twitter.com/', '') }}">
<meta name="twitter:title" content="{{ article.title | striptags }}">
<meta name="twitter:url" content="{{ SITEURL }}/{{ article.url }}">
{% if article.twitter_image %}
{% if article.twitter_image|lower|truncate(4, True, '') == "http" %}
<meta name="twitter:image:src" content="{{ article.twitter_image }}">
{% else %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ article.twitter_image }}">
{% endif %}
{% else %}
<meta name="twitter:image:src" content="{{ default_cover }}">
{% endif %}
<meta name="twitter:description" content="{{ description }}">
{% endfor %}