danielmochdotcom

Nikola site for www.danielmoch.com
git clone git://git.danielmoch.com/danielmochdotcom.git
Log | Files | Refs

commit ca8e5f10ac1a50929b64883ccd5f8c5fb4f164b1
parent 8ef216e95bfa6a1e621a94d721e7d59f9bdd22a2
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 12 Jul 2019 20:44:58 -0400

Add OG/Twitter metadata to home page

Diffstat:
Mthemes/djmoch/templates/index.tmpl | 2++
Athemes/djmoch/templates/index_helper.tmpl | 48++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/themes/djmoch/templates/index.tmpl b/themes/djmoch/templates/index.tmpl @@ -8,6 +8,8 @@ {% if posts and (permalink == '/' or permalink == '/' + index_file) %} <link rel="prefetch" href="{{ posts[0].permalink() }}" type="text/html"> {% endif %} + {{ helper.open_graph_metadata() }} + {{ helper.twitter_card_information() }} {% endblock %} {% block content %} diff --git a/themes/djmoch/templates/index_helper.tmpl b/themes/djmoch/templates/index_helper.tmpl @@ -0,0 +1,48 @@ +{# -*- coding: utf-8 -*- #} +{% import 'math_helper.tmpl' as math with context %} +{% macro html_pager() %} + {% if prevlink or nextlink %} + <nav class="postindexpager"> + <ul class="pager"> + {% if prevlink %} + <li class="previous"> + <a href="{{ prevlink }}" rel="prev">{{ messages("Newer posts") }}</a> + </li> + {% endif %} + {% if nextlink %} + <li class="next"> + <a href="{{ nextlink }}" rel="next">{{ messages("Older posts") }}</a> + </li> + {% endif %} + </ul> + </nav> + {% endif %} +{% endmacro %} + +{% macro open_graph_metadata() %} +<meta property="og:site_name" content="{{ blog_title|e }}"> +<meta property="og:title" content="{{ blog_title|e }}"> +<meta property="og:type" content="website"> +<meta property="og:image" content="{{ abs_link(logo_url) }}"> +{% 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 %} + +{# This function is deprecated; use math_helper directly. #} +{% macro mathjax_script(posts) %} + {{ math.math_scripts_ifposts(posts) }} +{% endmacro %}