Jane_Jojo
(Jane Jojo)
January 12, 2018, 9:12am
1
I have incorporated Discourse into my blog via
Discourse has the ability to embed the comments from a topic in a remote site using a Javascript API that creates an IFRAME. For an example of this in action, check out Coding Horror’s blog . The blog is run via Ghost but the comments are embedded from his Discourse forum .
One important thing to note with this setup is that users have to navigate to your forum to post replies. This is intentional, as we feel that the posting interface on a Discourse forum is currently much richer than what we …
This is the code I used
<div id='discourse-comments'></div>
<script type="text/rocketscript">
DiscourseEmbed = { discourseUrl: 'https://comments.alittlebitofspice.com/',
topicId: };
if(!DiscourseEmbed.topicId)
DiscourseEmbed.discourseEmbedUrl = 'https://www.alittlebitofspice.com/cauliflower-rice-stir-fry-with-eggs-paleo-keto-gluten-free-recipe';
(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>
Everything works except when topid is empty (for a new post).
How do I instruct discourse to create a new topic?
if(!DiscourseEmbed.topicId)
DiscourseEmbed.discourseEmbedUrl = 'https://www.alittlebitofspice.com/cauliflower-rice-stir-fry-with-eggs-paleo-keto-gluten-free-recipe';
Does not seem to work
Here’s my blog post
Try this Cauliflower Rice Stir Fry recipe with eggs, veggies, and low-carb goodness. Perfect for Paleo, Keto, and Gluten-Free diets!
Est. reading time: 3 minutes
and my embedding setup
You may be able to create a Topic on Your discourse using the WP-Discourse Plugin.
are You using it?
gerhard
(Gerhard Schlager)
January 12, 2018, 9:51am
3
Since you are using WordPress, I’d also recommend you look into the wp-discourse plugin. It should make your life a lot easier.
A few notes to your usage of the embedding feature:
You only need to use topicId when you want to point to an existing topic that wasn’t created by embedding.
Otherwise it should be fine to always use the discourseEmbedUrl with the URL of the blog post.
Jane_Jojo
(Jane Jojo)
January 12, 2018, 1:54pm
4
Thanks. WP-Discourse had too many issues.
So I can change the code to
DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
discourseEmbedUrl: 'http://example.com/blog/entry-123.html' };
and it should work, right?