Skip to content
Snippets Groups Projects
Commit e55a82b9 authored by squidfunk's avatar squidfunk Committed by Martin Donath
Browse files

Added ability to override Disqus integration using metadata

parent 25860b3b
Branches
Tags
No related merge requests found
......@@ -580,7 +580,7 @@ in your `mkdocs.yml`:
``` yaml
extra:
disqus: 'mkdocs-material'
disqus: 'your-shortname'
```
The comments section is inserted on *every page, except the index page*.
......
......@@ -154,8 +154,8 @@
{% endblock %}
{% endblock %}
{% block disqus %}
{% if config.extra.disqus and not page.is_homepage %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
{% if (config.extra.disqus and not page.is_homepage) or
(page and page.meta and page.meta.disqus) %}
{% include "partials/integrations/disqus.html" %}
{% endif %}
{% endblock %}
......
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}
{% if disqus %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
......@@ -7,8 +13,9 @@
};
(function() {
var d = document, s = d.createElement("script");
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
s.src = "//{{ disqus }}.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
{% endif %}
......@@ -17,7 +17,11 @@
</a>
</li>
{% endif %}
{% if config.extra.disqus and not page.is_homepage %}
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}
{% if disqus %}
<li class="md-nav__item">
<a href="#__comments" title="{{ lang.t('meta.comments') }}" class="md-nav__link md-nav__link--active">
{{ lang.t("meta.comments") }}
......
......@@ -288,8 +288,8 @@
<!-- Disqus integration -->
{% block disqus %}
{% if config.extra.disqus and not page.is_homepage %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
{% if (config.extra.disqus and not page.is_homepage) or
(page and page.meta and page.meta.disqus) %}
{% include "partials/integrations/disqus.html" %}
{% endif %}
{% endblock %}
......
......@@ -20,7 +20,15 @@
IN THE SOFTWARE.
-->
<!-- Set from config but allow override -->
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}
<!-- Disqus integration -->
{% if disqus %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
......@@ -30,8 +38,9 @@
};
(function() {
var d = document, s = d.createElement("script");
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
s.src = "//{{ disqus }}.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
{% endif %}
......@@ -55,7 +55,11 @@
{% endif %}
<!-- Disqus integration -->
{% if config.extra.disqus and not page.is_homepage %}
{% set disqus = config.extra.disqus %}
{% if page and page.meta and page.meta.disqus is string %}
{% set disqus = page.meta.disqus %}
{% endif %}
{% if disqus %}
<li class="md-nav__item">
<a href="#__comments" title="{{ lang.t('meta.comments') }}"
class="md-nav__link md-nav__link--active">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment