Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration/social-media-networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Long story short: on the the label on the left is included as is, followed by `=
* `permalink` is replaced with the permalink of the page (urlencoded)
* `title` is replaced with the title of the page (urlencoded)
* `description` is replaced with the frontmatter description
* `featured_image` is replaced with the featured image URL of the page (urlencoded)
* `username` is replaced with the configured `username` for that network (under the `ananke.social.$NETWORKSLUG` section)

Adding to that everything in `params` is added blindly to the resulting link.
Expand Down
34 changes: 21 additions & 13 deletions layouts/_partials/func/social/getShareLink.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@
{{- $title := $context.Title | transform.HTMLEscape -}}
{{- $description := $context.Summary | transform.Plainify | transform.HTMLEscape -}}
{{- $permalink := $context.Permalink | transform.HTMLEscape -}}
{{- $featured_image := "" -}}
{{- with partial "func/GetFeaturedImage.html" $context -}}
{{- $featured_image = . | absURL | transform.HTMLEscape -}}
{{- end -}}
{{- with $setup.separator -}}
{{- $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 -}}
{{- 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) -}}
{{- else if compare.Eq $value "featured_image" -}}
{{- if $featured_image -}}
{{- $link = fmt.Printf "%s%s%s" $link $separator (collections.Querify $key $featured_image) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $link -}}
{{- return $link -}}