mdBook
mdBook copied to clipboard
Inline comments
Like Gitbook or Disqus Inline Comments.
Possible? Worth it?
You mean, being able to directly comment paragraphs in the online book?
That is an interesting idea, but there would be some major problems with that. It would require a server to be running in the background to serve the comments, this means you don't have a static website anymore. It would make the setup more complicated, it would make local books less easy to read, you would not be able to deploy to Github pages anymore, etc. I don't really want to give that all up for comments.
Maybe it would be possible to only include the javascript part that queries a server for the comments and leave the whole server part up to the user. But I am not sure how that would work out.
Disqus is an online service for comments. It wouldnt change your setup at all. It just changes some parts of the html page that will load disqus comments into a predefined element. :)
Maybe this could be implemented as a plugin when I get them working :)
In the mean time, this functionality could be added by the user by overriding the handlebars template.
So any updates on this? Feels like it should be easy to add a disqus feature by updating index.hbs or?
I am not sure but seems only need to setup {{ page.url }}
,{{ page.id }}
and allow that SHORTNAME
to be configured via book.toml configurations, somehow.
Then it could also work with github pages.
I have also used this in my jekyll blogs and it seems working well.
Another reference: http://sgeos.github.io/jekyll/disqus/2016/02/14/adding-disqus-to-a-jekyll-blog.html
Nowdays GitHub has support for discussions, and leveraging that as a backend for comments would be very nifty.
The way I imagine this working is that there's some JavaScript with implements GoogeDoc/HackMd style "comment on the selected text in the marging", but where posing a comment posts to a GitHub disccussion instead on behalf of the user.
Requires a boatload of complex JS, but would be super nifty!
relevant https://www.freecodecamp.org/news/github-discussions-as-chat-system/
Nowdays GitHub has support for discussions, and leveraging that as a backend for comments would be very nifty.
The way I imagine this working is that there's some JavaScript with implements GoogeDoc/HackMd style "comment on the selected text in the marging", but where posing a comment posts to a GitHub disccussion instead on behalf of the user.
Requires a boatload of complex JS, but would be super nifty!
relevant https://www.freecodecamp.org/news/github-discussions-as-chat-system/
This works well and is an option that does exactly that:
https://giscus.app/
Easy to add.
So I managed to add giscus by modifying theme/index.hbs
as follows:
## Within your book root directory,
## Use `mdbook init --theme` first
## Modify the generated `theme/index.hbs`
## Go to <div id="content"> and add below {{ content }}
## The script generated by: https://giscus.app/
## e.g.:
<div id="content" class="content">
<main>
{{{ content }}}
<script src="https://giscus.app/client.js"
data-repo="[ENTER REPO HERE]"
data-repo-id="[ENTER REPO ID HERE]"
data-category="[ENTER CATEGORY NAME HERE]"
data-category-id="[ENTER CATEGORY ID HERE]"
data-mapping="pathname"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="preferred_color_scheme"
data-lang="en"
crossorigin="anonymous"
async>
</script>
</main>