From 4ab4f63d64baf91037351325fa246829bd2bff45 Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Sat, 24 Mar 2018 16:14:42 +0100 Subject: [PATCH] Disqus script loads when needed. Fixes #9 --- templates/_base.html | 3 +++ templates/blog/list.html | 6 ++++++ templates/blog/post.html | 8 ++++++-- templates/macros/comments.html | 12 ++++++------ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/templates/_base.html b/templates/_base.html index 6b64c51..a1a5898 100644 --- a/templates/_base.html +++ b/templates/_base.html @@ -12,6 +12,9 @@ + {% block endhead %}{% endblock %} diff --git a/templates/blog/list.html b/templates/blog/list.html index 92122f3..618dfd7 100644 --- a/templates/blog/list.html +++ b/templates/blog/list.html @@ -1,6 +1,7 @@ {% extends "blog/_base.html" %} {% from "macros/blog.html" import render_blog_post %} {% from "macros/pagination.html" import render_pagination %} +{% from "macros/comments.html" import render_count %} {% block main_content %} {% for child in this.pagination.items %} @@ -9,3 +10,8 @@
{{ render_pagination(this.pagination) }}
{% endblock %} + +{% block endbody %} + {{ super() }} + {{ disqus_count_script() }} +{% endblock %} diff --git a/templates/blog/post.html b/templates/blog/post.html index db2e57a..7985334 100644 --- a/templates/blog/post.html +++ b/templates/blog/post.html @@ -1,5 +1,6 @@ {% extends "blog/_base.html" %} {% from "macros/blog.html" import render_blog_post %} +{% from "macros/comments.html" import disqus_comments_script %} {% block body_class %}blog post{% endblock %} @@ -9,11 +10,14 @@ {{ render_blog_post(this) }} {% if this.comments_enabled %}
- {% from 'macros/comments.html' import disqus with context %} - {{ disqus() }} {% else %}
Comments have been disabled in this post, if you want to contact me please go ahead!
{% endif %} {% endblock %} + +{% block endbody %} + {{ super() }} + {{ disqus_comments_script() }} +{% endblock %} diff --git a/templates/macros/comments.html b/templates/macros/comments.html index 59ff5a0..fb59b5c 100644 --- a/templates/macros/comments.html +++ b/templates/macros/comments.html @@ -1,19 +1,19 @@ -{% macro disqus(shortname) -%} +{% macro disqus_comments_script() -%} +{%- endmacro %} -// Count +{% macro disqus_count_script() %} +