Link sidebar buttons and scripts

<script>
api.addCommunitySectionLink({
  name: "unread",
  route: "discovery.unread",
  title: I18n.t("some.unread.title"),
  text: I18n.t("some.unread.text"),
  icon: "fa-envelope"
});
</script>

I put it in the HTML body section of the component like this, but it does not seem to be added to more. Is not it possible to do it this way?