Hide mentions & backlinks if empty

What I’m trying to do

If a document doesn’t have any backlinks or mentions I want to hide this section completely.

Here’s a screenshot of what I’d like to avoid. Takes up space for no reason.

Things I have tried

It’s possible to disable the plugin globally and per document. Rather I’m searching for a dynamic solution that would only show the mentions and backlinks if there are any.