Modernizing inline script tags for templates & JS API

As a poke and guess admin I was a bit worried reading this, but when I checked my custom theme, I saw only a very simple script:

<script type="text/discourse-plugin" version="0.8.11">

// icon substitutions for share buttons
api.replaceIcon('d-post-share', 'up-right-from-square');
api.replaceIcon('d-topic-share', 'up-right-from-square');


</script>

So it was just a copy of whats between the script tags, hop to the JS tab, and there was a place to slap it in. That was easy!

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
	// icon substitutions for share buttons
	api.replaceIcon('d-post-share', 'up-right-from-square');
	api.replaceIcon('d-topic-share', 'up-right-from-square');
});
1 Like