How to handle / and @ in shortcodes?

I get errors with / and @ in shortcodes. How can I use them?

Examples:

{{< social youtube channel/example >}}
{{< social tiktok @example >}}

Then in social.html: ($youtube etc is SVG data)

{{ $type := .Get 0 }}
{{ $page := .Get 1 }}
{{ with (eq $type "youtube") }}<span class="box"><a href='https://www.youtube.com/{{ $page }}' target='_blank'>{{ $youtube | safeHTML }}</a></span>{{ end }}
{{ with (eq $type "tiktok") }}<span class="box"><a href='https://www.tiktok.com/{{ $page }}' target='_blank'>{{ $tiktok | safeHTML }}</a></span>{{ end }}

With named params?

{{< social type="youtube" id="channel/example" >}}
2 Likes

Thank you, here is the working correction:

{{< social type="youtube" id="channel/example" >}}
{{< social type="tiktok" id="@example" >}}

Then in social.html:

{{ $type := .Get "type" }}
{{ $page := .Get "id" }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.