Hi @Arkshine ,
Thank you so much for the detailed write-up. I tried injecting the code in <head>
but is not seeing the icon show up. What did I do wrong?
<script type="text/discourse-plugin">
import { apiInitializer } from "discourse/lib/api";
import DButton from "discourse/components/d-button";
export default apiInitializer("1.8.0", (api) => {
const currentUser = api.getCurrentUser();
if (!currentUser) {
return;
}
const url =
"https://example.com/?u=" + encodeURIComponent(currentUser.username);
console.log("url: " + url)
const iconComponent = <template>
<li class="calculator">
<DButton
@href={{url}}
@icon="calculator"
class="icon btn-flat"
title="Calculator"
target="_blank"
/>
</li>
</template>;
api.headerIcons.add("calculator", iconComponent, { before: "search" });
});
</script>