ananke/layouts/partials/func/social/getShareLink.html
Ramiro Morales 58e742ef62
theme(fix): share link building when params particle is present (#769)
In these cases the site permalink is used instead of the social network
URL for sharing as defined in the `link` value
(https://www.linkedin.com/shareArticle in the below example)

Most visible case is LinkedIn but all social networks that have

```toml
[ananke.social.networks.particles]
...
params = "..."
```

in `config/_default/params.toml` are affected by this bug.

Closes #768.
2024-10-26 06:05:18 +07:00

25 lines
1 KiB
HTML

{{- $context := .context -}}
{{- $setup := .setup -}}
{{- $separator := "&" -}}
{{- $title := $context.Title | transform.HTMLEscape -}}
{{- $description := $context.Summary | transform.Plainify | transform.HTMLEscape -}}
{{- $permalink := $context.Permalink | transform.HTMLEscape -}}
{{- with $setup.separator -}}
{{- $separator = . -}}
{{- end -}}
{{- $link := fmt.Printf "%s%s" $setup.link "?" -}}
{{- range $key, $value := $setup.particles -}}
{{- if compare.Eq $key "params" -}}
{{- $link = fmt.Printf "%s%s%s" $link $separator $value -}}
{{- else -}}
{{- if compare.Eq $value "description" -}}
{{- $link = fmt.Printf "%s%s%s" $link $separator (collections.Querify $key $description) -}}
{{- else if compare.Eq $value "title" -}}
{{- $link = fmt.Printf "%s%s%s" $link $separator (collections.Querify $key $title) -}}
{{- else if compare.Eq $value "permalink" -}}
{{- $link = fmt.Printf "%s%s%s" $link $separator (collections.Querify $key $permalink) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $link -}}