HUGO

Passing parameter to block template

I have a shortcode with a custom js footer , now I would like to forward the parameter {{ .Get 0 }} to the js block.

This isn’t possible as the block is rendered somewhere else. I pritty certains there is a solution but after hours of searching I still can’t find it. I tried it already with with .Scratch but it had not effect.

my shortcode.html

<span name="{{ .Get 0 }}"></span>
{{- define "footer_js" -}}
<script>
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const custom_domain = urlParams.get("d");
    for (const elem of document.getElementsByName("{{ . }}")) {
        elem.textContent=custom_domain!=undefined?custom_domain: "ccc.io";
    };
</script>
{{- end -}}

Can someone point me into the right direction?