Add the ability to show Discourse comments threads
aschrijver opened this issue · comments
Part of #12
Discourse integration is part of minimal mistakes
theme, and is documented here:
Will create a blog with a comment thread to test how this works. Two things to find out:
- Does the website auto-create a topic if a blog post has
comments: true
? - Is it possible to provide the URL to an existing topic to show as comments section?
Commenting works, BUT:
Handle with Care!
Followed instructions from Discourse meta: https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963
The feature needs to be fine-tuned still. Currently in Admin I configured the system
user as the one to auto-create threads, and specified the `Central / Announcements' category as the target for creation
Also I specified that ANY page may have comments added to them. This is too loose and needs to be restricted, unless we create a new special forum category where all Community Hub comment threads are stored. I think this is the best way forward.
The following blog post shows how Comments work:
And this auto-created the following forum topic:
Only thing needed to do was to add comments: true
to the frontmatter section of the blog post.
Concluding: Method 1 auto-create works.
Edit: No longer need to 'handle with care'. Topics are now added to 'Uncategorized' category.
Bug
The functionality now creates topics in the forum for any blog post (maybe any page) that is opened in the website. Need to check what's wrong (maybe commenting defaults to true
).
Fixed that bug. Now for method 2). This is document at meta.discourse.org - see the documentation below. Need to check whether this needs the Admin Embedding functionality too, and whether you should explicitly add the code, or also the Topic ID can be specified in the website (would be great).
I created 2 more issues to follow up on later, after the MVP concludes:
- Create a separate forum topic for Community Hub discussions? (#47)
- Test Discourse integration for existing forum topics (#46)
(Alternate Configuration) Linking to existing topics
Some people prefer to not have Discourse create topics for them automatically on their forums. They’d like to create the topics themselves, then simply tell their embedding code what topic they want to associate with. You can do this by slightly changing your embedding code:
<div id='discourse-comments'></div>
<script type="text/javascript">
DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
topicId: 12345 };
(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>
The only difference here is we’ve replaced discourseEmbedUrl with the id of a topic from Discourse. If you do this, no topic will be created and the comments from that topic will automatically be displayed.
Method 2) is currently not supported, so you cannot attach an existing forum discussion. See #46 for options to PR this functionality to minimal-mistakes
.