I created GitHub - literatecomputing/discourse-custom-components as an example of how to do that.
Is a trivial example of inserting a component. So you would add some code before <template>
to get the topic id and logic for whether to display.
I think you might want topic-list-before-link
as the plugin outlet.