Skip to content

Commit

Permalink
feat: added support for Disqus (#120)
Browse files Browse the repository at this point in the history
* feat: added support for Disqus
* feat: allow disqus to be disabled through frontmatter

Set:
    bookDisableComments: true

On a page to disable disqus for the content.
  • Loading branch information
dwmkerr authored and alex-shpak committed Jan 13, 2020
1 parent e037b7c commit 36a8cf5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Customisable
- Zero initial configuration
- Handy shortcodes
- Optional support for Disqus

## Requirements

Expand Down Expand Up @@ -117,6 +118,10 @@ You can also see `yaml` example [here](https://github.com/alex-shpak/hugo-book/b
# Always put it on the top of the configuration file, otherwise it won't work
googleAnalytics = "UA-XXXXXXXXX-X"

# (Optional) If you provide a Disqus shortname, comments will be enabled on
# all pages.
disqusShortname = "my-site"

# (Optional) Set this to true if you use capital letters in file names
disablePathToLower = true

Expand Down Expand Up @@ -190,6 +195,9 @@ bookHidden = true

# (Optional) Set how many levels of ToC to show. use 'false' to hide ToC completely
bookToC = 3

# If you have enabled Disqus for the site, you can disable it for specific pages.
bookDisableComments = true
```

### Partials
Expand Down
6 changes: 6 additions & 0 deletions assets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ ul.pagination {
}
}

// Give a little extra space before showing Disqus comments. See:
// https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/disqus.html#L3
#disqus_thread {
padding-top: $padding-16;
}

.book-languages {
position: relative;
overflow: visible;
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/docs/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
{{ end }}

</div>

{{ if and (not (eq .Site.DisqusShortname "")) (not .Params.bookDisableComments ) }}
{{ template "_internal/disqus.html" . }}
{{ end }}

0 comments on commit 36a8cf5

Please sign in to comment.