Custom sidebar link willDestroy function has to be passed to SidebarLink component to call when component is removed. Very similar to https://github.com/discourse/discourse/pull/17551
This plugin API can be used to add to sections and links to sidebar