From de3bd8d665f2637335b60480ac49cca0b3084557 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Fri, 24 Feb 2017 22:53:12 +0100 Subject: [PATCH] Added disqus integration --- docs/getting-started.md | 59 +++++++++++++++++++++------------ material/base.html | 19 +++++++++++ material/partials/language.html | 1 + src/base.html | 22 +++++++++++- src/partials/language.html | 1 + 5 files changed, 80 insertions(+), 22 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index c2ed556e9..314d32c49 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -246,7 +246,7 @@ extra: ``` [12]: https://fonts.google.com/specimen/Roboto - [13]: https://fonts.google.com/ + [13]: https://fonts.google.com [14]: https://fonts.google.com/specimen/Ubuntu ### Adding a logo @@ -300,6 +300,21 @@ google_analytics: - '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 L10N In order to localize the labels (e.g. *Previous* and *Next* in the footer), @@ -309,6 +324,7 @@ translations inside the macro `t`: ``` jinja {% macro t(key) %}{{ { "edit.link.title": "Edit this page", + "comments": "Comments", "footer.previous": "Previous", "footer.next": "Next", "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 -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" @@ -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 will be ignored. - [16]: customization.md#overriding-partials + [17]: customization.md#overriding-partials ### More advanced customization 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 -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) 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 Material theme including more information regarding installation and usage: -* [Admonition][19] -* [Codehilite][20] -* [Permalinks][21] -* [Footnotes][22] -* [PyMdown Extensions][23] +* [Admonition][20] +* [Codehilite][21] +* [Permalinks][22] +* [Footnotes][23] +* [PyMdown Extensions][24] - [18]: http://www.mkdocs.org/user-guide/writing-your-docs/#markdown-extensions - [19]: extensions/admonition.md - [20]: extensions/codehilite.md - [21]: extensions/permalinks.md - [22]: extensions/footnotes.md - [23]: extensions/pymdown.md + [19]: http://www.mkdocs.org/user-guide/writing-your-docs/#markdown-extensions + [20]: extensions/admonition.md + [21]: extensions/codehilite.md + [22]: extensions/permalinks.md + [23]: extensions/footnotes.md + [24]: extensions/pymdown.md ## Full example @@ -380,7 +396,7 @@ repo_name: 'GitHub' repo_url: 'https://github.com/my-github-handle/my-project' # Copyright -copyright: 'Copyright © 2016 John Doe' +copyright: 'Copyright © 2016 - 2017 John Doe' # Documentation and theme theme: 'material' @@ -394,13 +410,14 @@ extra: font: text: 'Roboto' code: 'Roboto Mono' + disqus: 'your-disqus-shortname' social: - type: 'github' - link: 'https://github.com/squidfunk' + link: 'https://github.com/john-doe' - type: 'twitter' - link: 'https://twitter.com/squidfunk' + link: 'https://twitter.com/jonh-doe' - type: 'linkedin' - link: 'https://de.linkedin.com/in/martin-donath-20a95039' + link: 'https://de.linkedin.com/in/john-doe' # Google Analytics google_analytics: diff --git a/material/base.html b/material/base.html index f983e3a47..590418027 100644 --- a/material/base.html +++ b/material/base.html @@ -1,3 +1,5 @@ +' +' {% import "partials/language.html" as lang %} @@ -115,6 +117,23 @@ {% endif %} {{ page.content }} {% endblock %} + {% if config.extra.disqus and not page.is_homepage %} +

{{ lang.t('comments') }}

+
+ + {% endif %} diff --git a/material/partials/language.html b/material/partials/language.html index bf43cf588..9e00a86f3 100644 --- a/material/partials/language.html +++ b/material/partials/language.html @@ -1,5 +1,6 @@ {% macro t(key) %}{{ { "edit.link.title": "Edit this page", + "comments": "Comments", "footer.previous": "Previous", "footer.next": "Next", "search.placeholder": "Search", diff --git a/src/base.html b/src/base.html index b619ca099..5771344cd 100644 --- a/src/base.html +++ b/src/base.html @@ -1,4 +1,5 @@ - {{ page.content }} {% endblock %} + + + {% if config.extra.disqus and not page.is_homepage %} +

{{ lang.t('comments') }}

+
+ + {% endif %} diff --git a/src/partials/language.html b/src/partials/language.html index bf8702f6d..9381c0d4d 100644 --- a/src/partials/language.html +++ b/src/partials/language.html @@ -23,6 +23,7 @@ {% macro t(key) %}{{ { "edit.link.title": "Edit this page", + "comments": "Comments", "footer.previous": "Previous", "footer.next": "Next", "search.placeholder": "Search",