I handled this by using Discourse Theme CLI in the following way:
-
Created a new theme and made it a component (ran
discourse_theme newand followed the prompts). -
In
javascripts/discourse/connectors/badge-contents-topcreated a JavaScript file with content not far from. . .import Component from "@glimmer/component"; import { inject as service } from "@ember/service"; export default class LinkedinButton extends Component { @service siteSettings; get encodedUrl() { return encodeURIComponent(this.args.outletArgs.url); } } -
In the same directory as above, created a Handlebars file that roughly contains the inner HTML from the script tag in the question.
- I gave this and the previous file the same name, other than their termination, that is, for what it’s worth.