diff --git a/README.md b/README.md index 8e79e7b..cb69c36 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,13 @@ Accept many analytics: - Gauges: ``GAUGES`` - Piwik: ``PIWIK_URL`` and ``PIWIK_SITE_ID``. +### Twitter cards + +Twitter cards are automatically generated if TWITTER_HANDLE is set: +```python +TWITTER_HANDLE = "myprofile" +``` + ### Other configuration - If ``ADDTHIS_PUBID`` is defined sharing buttons from AddThis will appear diff --git a/templates/article.html b/templates/article.html index 12332b0..4fbdcda 100755 --- a/templates/article.html +++ b/templates/article.html @@ -25,6 +25,36 @@ {% endfor %} {% endblock %} +{% block twitter_card %} + {% if TWITTER_HANDLE %} + {% if article.header_cover %} + + + {% elif HEADER_COVER %} + + + {% else %} + + + {% endif %} + + + {% if description %} + + {% elif article.headline %} + + {% else %} + + {% endif %} + {% if article.header_cover %} + + {% elif HEADER_COVER %} + + {% else %} + + {% endif %} + {% endif %} +{% endblock %} {% block opengraph %} {{ super() }} diff --git a/templates/base.html b/templates/base.html index 8d80afa..130a43c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -78,6 +78,23 @@ {% endfor %} {% endblock opengraph %} + {% block twitter_card %} + {% if TWITTER_HANDLE %} + + + + {% if SITESUBTITLE %} + + {% else %} + + {% endif %} + {% if HEADER_COVER %} + + {% else %} + + {% endif %} + {% endif %} + {% endblock twitter_card %}