getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 444 forks source link

Discourse comments #3689

Closed Mte90 closed 1 year ago

Mte90 commented 1 year ago

There is a discourse plugin for jekyll https://github.com/oblakeerickson/jekyll_discourse_comments/blob/master/discourse_comments.rb as we can see just print a javascript code with the url of the discourse thread. So a nikola plugin should have just a parameter in the article and the plugin installed.

Kwpolska commented 1 year ago

(Moved from getnikola/plugins to getnikola/nikola, as comment systems cannot be plugins.)

Mte90 commented 1 year ago

Note for myself to work on this:

My doubt is how to get in the template the new field that I have to add for the discourse thread link. The comment_link_script macro doesn't have the post object and the comment_form doesn't have the post object too.

Kwpolska commented 1 year ago

Looking at the Jekyll plugin and at this Discourse forum thread, the discourseEmbedUrl is just the post URL, and the comment_form function gets the URL as a parameter. (comment_link_script is used on index pages, it is a script that shows the comment count in post headers — this is an optional feature.)

Mte90 commented 1 year ago

You are right, a html snippet generate by the jekyll plugin:

<script type="text/javascript">
                            DiscourseEmbed = { discourseUrl: 'https://forum.linux.it/',
                            discourseEmbedUrl: 'https://www.ils.org/2023/05/10/mergeit-2023.html' };

                            (function() {
                                var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
                                d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
                                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
                            })();
                        </script>