Resolve embedded links to full URL

I enabled embedded links resolution like so:

[markup.goldmark.renderHooks.link]
useEmbedded = "fallback"

This works great for [xyz](/posts/xyz.md), except that the resolves URL is relative to the URL root, and I’d like it to be a full URL. I tried modifying the default template to prefix {{ .Page.Site.BaseURL }}:

<a href="{{ .Page.Site.BaseURL }}{{ .Destination | safeURL }}"
  {{- with .Title }} title="{{ . }}"{{ end -}}
>
  {{- with .Text }}{{ . }}{{ end -}}
</a>
{{- /* chomp trailing newline */ -}}

But then it’s prepended to links that are already full; I end up with stuff like href="``https://jusatheory.com/https://xyz.com``". Is there some other config I can adjust to get the full URL just for internally-resolved embedded links? Or else to prepend the base URL only to such internally-resolved links?

Thank you!

You may find some inspiration here:

Perfect, thank you. Here’s my version.

There is almost never a good reason to use .BaseURL.

Copy the embedded render hook, and change .RelPermalink to .Permalink.

Of course, thank you. I’ve done little with templates in a few years so forget all the bits.