Skip to content

Commit ffcb97a

Browse files
committed
another attempt
1 parent 9825f72 commit ffcb97a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

themes/devopsdays-theme/layouts/partials/footer_scripts.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
{{- $.Scratch.Set "sharing_title" "devopsdays" -}}
5252
{{- end -}}
5353
{{- end -}}
54+
{{- /* Set default shares for non-event pages */ -}}
55+
{{- $default_shares := slice "email" (dict "share" "twitter" "via" "devopsdays") "facebook" "linkedin" -}}
56+
{{- $.Scratch.Set "social_shares" $default_shares -}}
5457
{{- end -}}
5558
{{- end -}}
5659
{{- /* Ensure sharing_title is always set */ -}}
@@ -67,8 +70,12 @@
6770
{{- range $shares -}}
6871
{{- $share_str := "" -}}
6972
{{- $current_item := . -}}
70-
{{- if or (eq $current_item "email") (eq $current_item "facebook") (eq $current_item "linkedin") -}}
71-
{{- $share_str = printf "\"%s\"" $current_item -}}
73+
{{- if eq $current_item "email" -}}
74+
{{- $share_str = "\"email\"" -}}
75+
{{- else if eq $current_item "facebook" -}}
76+
{{- $share_str = "\"facebook\"" -}}
77+
{{- else if eq $current_item "linkedin" -}}
78+
{{- $share_str = "\"linkedin\"" -}}
7279
{{- else -}}
7380
{{- $twitter_share_val := index $current_item "share" -}}
7481
{{- if $twitter_share_val -}}
@@ -80,6 +87,9 @@
8087
{{- end -}}
8188
{{- end -}}
8289
{{- $shares_js_str := delimit $shares_js_parts ", " -}}
90+
{{- if not $shares_js_str -}}
91+
{{- $shares_js_str = "\"email\", {share: \"twitter\", via: 'devopsdays'}, \"facebook\", \"linkedin\"" -}}
92+
{{- end -}}
8393
{{- $.Scratch.Set "shares_js" $shares_js_str -}}
8494

8595
<script>
@@ -88,9 +98,12 @@
8898

8999
$(document).ready(function () {
90100
//YOUR JQUERY CODE
91-
101+
{{- $shares_js_final := $.Scratch.Get "shares_js" -}}
102+
{{- if not $shares_js_final -}}
103+
{{- $shares_js_final = "\"email\", {share: \"twitter\", via: 'devopsdays'}, \"facebook\", \"linkedin\"" -}}
104+
{{- end -}}
92105
$("#share").jsSocials({
93-
shares: [{{ $.Scratch.Get "shares_js" }}],
106+
shares: [{{ $shares_js_final }}],
94107
text: '{{ ($.Scratch.Get "sharing_title") }}',
95108
showLabel: false,
96109
showCount: false

0 commit comments

Comments
 (0)