mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added ability to override Disqus integration using metadata
This commit is contained in:
parent
25860b3bbf
commit
e55a82b96c
@ -580,7 +580,7 @@ in your `mkdocs.yml`:
|
|||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
extra:
|
extra:
|
||||||
disqus: 'mkdocs-material'
|
disqus: 'your-shortname'
|
||||||
```
|
```
|
||||||
|
|
||||||
The comments section is inserted on *every page, except the index page*.
|
The comments section is inserted on *every page, except the index page*.
|
||||||
|
@ -154,8 +154,8 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block disqus %}
|
{% block disqus %}
|
||||||
{% if config.extra.disqus and not page.is_homepage %}
|
{% if (config.extra.disqus and not page.is_homepage) or
|
||||||
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
|
(page and page.meta and page.meta.disqus) %}
|
||||||
{% include "partials/integrations/disqus.html" %}
|
{% include "partials/integrations/disqus.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
<div id="disqus_thread"></div>
|
{% set disqus = config.extra.disqus %}
|
||||||
<script>
|
{% if page and page.meta and page.meta.disqus is string %}
|
||||||
var disqus_config = function () {
|
{% set disqus = page.meta.disqus %}
|
||||||
this.page.url = "{{ page.canonical_url }}";
|
{% endif %}
|
||||||
this.page.identifier =
|
{% if disqus %}
|
||||||
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
|
||||||
};
|
<div id="disqus_thread"></div>
|
||||||
(function() {
|
<script>
|
||||||
var d = document, s = d.createElement("script");
|
var disqus_config = function () {
|
||||||
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
|
this.page.url = "{{ page.canonical_url }}";
|
||||||
s.setAttribute("data-timestamp", +new Date());
|
this.page.identifier =
|
||||||
(d.head || d.body).appendChild(s);
|
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
||||||
})();
|
};
|
||||||
</script>
|
(function() {
|
||||||
|
var d = document, s = d.createElement("script");
|
||||||
|
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>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% 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">
|
<li class="md-nav__item">
|
||||||
<a href="#__comments" title="{{ lang.t('meta.comments') }}" class="md-nav__link md-nav__link--active">
|
<a href="#__comments" title="{{ lang.t('meta.comments') }}" class="md-nav__link md-nav__link--active">
|
||||||
{{ lang.t("meta.comments") }}
|
{{ lang.t("meta.comments") }}
|
||||||
|
@ -288,8 +288,8 @@
|
|||||||
|
|
||||||
<!-- Disqus integration -->
|
<!-- Disqus integration -->
|
||||||
{% block disqus %}
|
{% block disqus %}
|
||||||
{% if config.extra.disqus and not page.is_homepage %}
|
{% if (config.extra.disqus and not page.is_homepage) or
|
||||||
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
|
(page and page.meta and page.meta.disqus) %}
|
||||||
{% include "partials/integrations/disqus.html" %}
|
{% include "partials/integrations/disqus.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -20,18 +20,27 @@
|
|||||||
IN THE SOFTWARE.
|
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 -->
|
<!-- Disqus integration -->
|
||||||
<div id="disqus_thread"></div>
|
{% if disqus %}
|
||||||
<script>
|
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
|
||||||
var disqus_config = function () {
|
<div id="disqus_thread"></div>
|
||||||
this.page.url = "{{ page.canonical_url }}";
|
<script>
|
||||||
this.page.identifier =
|
var disqus_config = function () {
|
||||||
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
this.page.url = "{{ page.canonical_url }}";
|
||||||
};
|
this.page.identifier =
|
||||||
(function() {
|
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
||||||
var d = document, s = d.createElement("script");
|
};
|
||||||
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
|
(function() {
|
||||||
s.setAttribute("data-timestamp", +new Date());
|
var d = document, s = d.createElement("script");
|
||||||
(d.head || d.body).appendChild(s);
|
s.src = "//{{ disqus }}.disqus.com/embed.js";
|
||||||
})();
|
s.setAttribute("data-timestamp", +new Date());
|
||||||
</script>
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
@ -55,7 +55,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Disqus integration -->
|
<!-- 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">
|
<li class="md-nav__item">
|
||||||
<a href="#__comments" title="{{ lang.t('meta.comments') }}"
|
<a href="#__comments" title="{{ lang.t('meta.comments') }}"
|
||||||
class="md-nav__link md-nav__link--active">
|
class="md-nav__link md-nav__link--active">
|
||||||
|
Loading…
Reference in New Issue
Block a user