How to add custom topic map code?

Hi again, I am continuing the discussion from Show topic-map without a reply, because it has been closed. [1]

That’s super sweet. Thank you, Jammy. May I humbly ask how/where this JavaScript snippet should be applied to make it work?

<script type="text/discourse-plugin" version="0.8">
  api.includePostAttributes('topicMap');
</script>

  1. a) Why? b) Feel free to refactor and/or re-open, as you see fit. ↩︎

Hi,

You can add it to your theme or in a new theme component HTML.

Usually, in a theme or component (Admin → Customize → Themes), you click on Edit CSS/HTML:

image

Then, you click on Head and you can insert the code there:

image

That’s it! :slight_smile:

2 Likes

Dear Arkshine,

that worked like a charm, thank you. For example, on this post, there have been no comments yet, so we never have been able to know about its pageviews, and other metadata.

With the improvements implemented by @pmusaraj [1], shared by @Don [2], and popularized by @JammyDodger, it works like DWIM. I love it, thank you very much!


  1. FIX: Don't force show topic map on non-first posts by pmusaraj · Pull Request #19302 · discourse/discourse · GitHub ↩︎

  2. How to show topic-map on non-commented posts? - #15 by Don ↩︎

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.