aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/data/themes/base-jinja/templates/post_helper.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/data/themes/base-jinja/templates/post_helper.tmpl')
-rw-r--r--nikola/data/themes/base-jinja/templates/post_helper.tmpl76
1 files changed, 76 insertions, 0 deletions
diff --git a/nikola/data/themes/base-jinja/templates/post_helper.tmpl b/nikola/data/themes/base-jinja/templates/post_helper.tmpl
new file mode 100644
index 0000000..c695e57
--- /dev/null
+++ b/nikola/data/themes/base-jinja/templates/post_helper.tmpl
@@ -0,0 +1,76 @@
+{# -*- coding: utf-8 -*- #}
+
+{% macro meta_translations(post) %}
+ {% if translations|length > 1 %}
+ {% for langname in translations.keys() %}
+ {% if langname != lang and post.is_translation_available(langname) %}
+ <link rel="alternate" hreflang="{{ langname }}" href="{{ post.permalink(langname) }}">
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+{% endmacro %}
+
+{% macro html_tags(post) %}
+ {% if post.tags %}
+ <ul itemprop="keywords" class="tags">
+ {% for tag in post.tags %}
+ <li><a class="tag p-category" href="{{ _link('tag', tag) }}" rel="tag">{{ tag }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+{% endmacro %}
+
+{% macro html_pager(post) %}
+ {% if post.prev_post or post.next_post %}
+ <ul class="pager">
+ {% if post.prev_post %}
+ <li class="previous">
+ <a href="{{ post.prev_post.permalink() }}" rel="prev" title="{{ post.prev_post.title() }}">{{ messages("Previous post") }}</a>
+ </li>
+ {% endif %}
+ {% if post.next_post %}
+ <li class="next">
+ <a href="{{ post.next_post.permalink() }}" rel="next" title="{{ post.next_post.title() }}">{{ messages("Next post") }}</a>
+ </li>
+ {% endif %}
+ </ul>
+ {% endif %}
+{% endmacro %}
+
+{% macro open_graph_metadata(post) %}
+ {% if use_open_graph %}
+ <meta name="og:title" content="{{ post.title()[:70]|e }}">
+ <meta name="og:url" content="{{ abs_link(permalink) }}">
+ {% if post.description() %}
+ <meta name="og:description" content="{{ post.description()[:200]|e }}">
+ {% else %}
+ <meta name="og:description" content="{{ post.text(strip_html=True)[:200]|e }}">
+ {% endif %}
+ <meta name="og:site_name" content="{{ blog_title|e }}">
+ <meta name="og:type" content="article">
+ {% endif %}
+{% endmacro %}
+
+{% macro twitter_card_information(post) %}
+ {% if twitter_card and twitter_card['use_twitter_cards'] %}
+ <meta name="twitter:card" content="{{ twitter_card.get('card', 'summary')|e }}">
+ {% if 'site:id' in twitter_card %}
+ <meta name="twitter:site:id" content="{{ twitter_card['site:id'] }}">
+ {% elif 'site' in twitter_card %}
+ <meta name="twitter:site" content="{{ twitter_card['site'] }}">
+ {% endif %}
+ {% if 'creator:id' in twitter_card %}
+ <meta name="twitter:creator:id" content="{{ twitter_card['creator:id'] }}">
+ {% elif 'creator' in twitter_card %}
+ <meta name="twitter:creator" content="{{ twitter_card['creator'] }}">
+ {% endif %}
+ {% endif %}
+{% endmacro %}
+
+{% macro mathjax_script(post) %}
+ {% if post.is_mathjax %}
+ <script type="text/x-mathjax-config">
+ MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});</script>
+ <script src="/assets/js/mathjax.js"></script>
+ {% endif %}
+{% endmacro %}