mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added disqus integration
This commit is contained in:
parent
ad39b98734
commit
de3bd8d665
@ -246,7 +246,7 @@ extra:
|
|||||||
```
|
```
|
||||||
|
|
||||||
[12]: https://fonts.google.com/specimen/Roboto
|
[12]: https://fonts.google.com/specimen/Roboto
|
||||||
[13]: https://fonts.google.com/
|
[13]: https://fonts.google.com
|
||||||
[14]: https://fonts.google.com/specimen/Ubuntu
|
[14]: https://fonts.google.com/specimen/Ubuntu
|
||||||
|
|
||||||
### Adding a logo
|
### Adding a logo
|
||||||
@ -300,6 +300,21 @@ google_analytics:
|
|||||||
- 'auto'
|
- 'auto'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Disqus integation
|
||||||
|
|
||||||
|
Material for MkDocs is integrated with [Disqus][16], so if you want to add a
|
||||||
|
comments section to your documentation set the shortname of your Disqus project
|
||||||
|
in your `mkdocs.yml`:
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
extra:
|
||||||
|
disqus: 'your-disqus-shortname'
|
||||||
|
```
|
||||||
|
|
||||||
|
The necessary JavaScript is automatically included.
|
||||||
|
|
||||||
|
[16]: https://disqus.com
|
||||||
|
|
||||||
### Localization <small>L10N</small>
|
### Localization <small>L10N</small>
|
||||||
|
|
||||||
In order to localize the labels (e.g. *Previous* and *Next* in the footer),
|
In order to localize the labels (e.g. *Previous* and *Next* in the footer),
|
||||||
@ -309,6 +324,7 @@ translations inside the macro `t`:
|
|||||||
``` jinja
|
``` jinja
|
||||||
{% macro t(key) %}{{ {
|
{% macro t(key) %}{{ {
|
||||||
"edit.link.title": "Edit this page",
|
"edit.link.title": "Edit this page",
|
||||||
|
"comments": "Comments",
|
||||||
"footer.previous": "Previous",
|
"footer.previous": "Previous",
|
||||||
"footer.next": "Next",
|
"footer.next": "Next",
|
||||||
"search.placeholder": "Search",
|
"search.placeholder": "Search",
|
||||||
@ -318,7 +334,7 @@ translations inside the macro `t`:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Just copy the file from the original theme and make your adjustments. See the
|
Just copy the file from the original theme and make your adjustments. See the
|
||||||
section on [overriding partials][16] in the customization guide.
|
section on [overriding partials][17] in the customization guide.
|
||||||
|
|
||||||
!!! warning "Migrating from Material 0.2.x"
|
!!! warning "Migrating from Material 0.2.x"
|
||||||
|
|
||||||
@ -326,18 +342,18 @@ section on [overriding partials][16] in the customization guide.
|
|||||||
`mkdocs.yml`. With 1.0.0 this is no longer possible as the configuration
|
`mkdocs.yml`. With 1.0.0 this is no longer possible as the configuration
|
||||||
will be ignored.
|
will be ignored.
|
||||||
|
|
||||||
[16]: customization.md#overriding-partials
|
[17]: customization.md#overriding-partials
|
||||||
|
|
||||||
### More advanced customization
|
### More advanced customization
|
||||||
|
|
||||||
If you want to change the general appearance of the Material theme, see
|
If you want to change the general appearance of the Material theme, see
|
||||||
[this article][17] for more information on advanced customization.
|
[this article][18] for more information on advanced customization.
|
||||||
|
|
||||||
[17]: customization.md
|
[18]: customization.md
|
||||||
|
|
||||||
## Extensions
|
## Extensions
|
||||||
|
|
||||||
MkDocs supports several [Markdown extensions][18]. The following extensions
|
MkDocs supports several [Markdown extensions][19]. The following extensions
|
||||||
are not enabled by default (see the link for which are enabled by default)
|
are not enabled by default (see the link for which are enabled by default)
|
||||||
but highly recommended, so they should be switched on at all times:
|
but highly recommended, so they should be switched on at all times:
|
||||||
|
|
||||||
@ -351,18 +367,18 @@ markdown_extensions:
|
|||||||
For more information, see the following list of extensions supported by the
|
For more information, see the following list of extensions supported by the
|
||||||
Material theme including more information regarding installation and usage:
|
Material theme including more information regarding installation and usage:
|
||||||
|
|
||||||
* [Admonition][19]
|
* [Admonition][20]
|
||||||
* [Codehilite][20]
|
* [Codehilite][21]
|
||||||
* [Permalinks][21]
|
* [Permalinks][22]
|
||||||
* [Footnotes][22]
|
* [Footnotes][23]
|
||||||
* [PyMdown Extensions][23]
|
* [PyMdown Extensions][24]
|
||||||
|
|
||||||
[18]: http://www.mkdocs.org/user-guide/writing-your-docs/#markdown-extensions
|
[19]: http://www.mkdocs.org/user-guide/writing-your-docs/#markdown-extensions
|
||||||
[19]: extensions/admonition.md
|
[20]: extensions/admonition.md
|
||||||
[20]: extensions/codehilite.md
|
[21]: extensions/codehilite.md
|
||||||
[21]: extensions/permalinks.md
|
[22]: extensions/permalinks.md
|
||||||
[22]: extensions/footnotes.md
|
[23]: extensions/footnotes.md
|
||||||
[23]: extensions/pymdown.md
|
[24]: extensions/pymdown.md
|
||||||
|
|
||||||
## Full example
|
## Full example
|
||||||
|
|
||||||
@ -380,7 +396,7 @@ repo_name: 'GitHub'
|
|||||||
repo_url: 'https://github.com/my-github-handle/my-project'
|
repo_url: 'https://github.com/my-github-handle/my-project'
|
||||||
|
|
||||||
# Copyright
|
# Copyright
|
||||||
copyright: 'Copyright © 2016 John Doe'
|
copyright: 'Copyright © 2016 - 2017 John Doe'
|
||||||
|
|
||||||
# Documentation and theme
|
# Documentation and theme
|
||||||
theme: 'material'
|
theme: 'material'
|
||||||
@ -394,13 +410,14 @@ extra:
|
|||||||
font:
|
font:
|
||||||
text: 'Roboto'
|
text: 'Roboto'
|
||||||
code: 'Roboto Mono'
|
code: 'Roboto Mono'
|
||||||
|
disqus: 'your-disqus-shortname'
|
||||||
social:
|
social:
|
||||||
- type: 'github'
|
- type: 'github'
|
||||||
link: 'https://github.com/squidfunk'
|
link: 'https://github.com/john-doe'
|
||||||
- type: 'twitter'
|
- type: 'twitter'
|
||||||
link: 'https://twitter.com/squidfunk'
|
link: 'https://twitter.com/jonh-doe'
|
||||||
- type: 'linkedin'
|
- type: 'linkedin'
|
||||||
link: 'https://de.linkedin.com/in/martin-donath-20a95039'
|
link: 'https://de.linkedin.com/in/john-doe'
|
||||||
|
|
||||||
# Google Analytics
|
# Google Analytics
|
||||||
google_analytics:
|
google_analytics:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
'
|
||||||
|
'
|
||||||
{% import "partials/language.html" as lang %}
|
{% import "partials/language.html" as lang %}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js">
|
<html class="no-js">
|
||||||
@ -115,6 +117,23 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{{ page.content }}
|
{{ page.content }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
{% if config.extra.disqus and not page.is_homepage %}
|
||||||
|
<h2>{{ lang.t('comments') }}</h2>
|
||||||
|
<div id="disqus_thread"></div>
|
||||||
|
<script>
|
||||||
|
var disqus_config = function () {
|
||||||
|
this.page.url = "{{ page.canonical_url }}";
|
||||||
|
this.page.identifier =
|
||||||
|
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
||||||
|
};
|
||||||
|
(function() {
|
||||||
|
var d = document, s = d.createElement("script");
|
||||||
|
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
|
||||||
|
s.setAttribute("data-timestamp", +new Date());
|
||||||
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% macro t(key) %}{{ {
|
{% macro t(key) %}{{ {
|
||||||
"edit.link.title": "Edit this page",
|
"edit.link.title": "Edit this page",
|
||||||
|
"comments": "Comments",
|
||||||
"footer.previous": "Previous",
|
"footer.previous": "Previous",
|
||||||
"footer.next": "Next",
|
"footer.next": "Next",
|
||||||
"search.placeholder": "Search",
|
"search.placeholder": "Search",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<!--
|
'
|
||||||
|
'<!--
|
||||||
Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -230,6 +231,25 @@
|
|||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
{{ page.content }}
|
{{ page.content }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<!-- Disqus integration -->
|
||||||
|
{% if config.extra.disqus and not page.is_homepage %}
|
||||||
|
<h2>{{ lang.t('comments') }}</h2>
|
||||||
|
<div id="disqus_thread"></div>
|
||||||
|
<script>
|
||||||
|
var disqus_config = function () {
|
||||||
|
this.page.url = "{{ page.canonical_url }}";
|
||||||
|
this.page.identifier =
|
||||||
|
"{{ page.canonical_url | replace(config.site_url, "") }}";
|
||||||
|
};
|
||||||
|
(function() {
|
||||||
|
var d = document, s = d.createElement("script");
|
||||||
|
s.src = "//{{ config.extra.disqus }}.disqus.com/embed.js";
|
||||||
|
s.setAttribute("data-timestamp", +new Date());
|
||||||
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<!-- Translations -->
|
<!-- Translations -->
|
||||||
{% macro t(key) %}{{ {
|
{% macro t(key) %}{{ {
|
||||||
"edit.link.title": "Edit this page",
|
"edit.link.title": "Edit this page",
|
||||||
|
"comments": "Comments",
|
||||||
"footer.previous": "Previous",
|
"footer.previous": "Previous",
|
||||||
"footer.next": "Next",
|
"footer.next": "Next",
|
||||||
"search.placeholder": "Search",
|
"search.placeholder": "Search",
|
||||||
|
Loading…
Reference in New Issue
Block a user