|
51 | 51 | {{- $.Scratch.Set "sharing_title" "devopsdays" -}} |
52 | 52 | {{- end -}} |
53 | 53 | {{- 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 -}} |
54 | 57 | {{- end -}} |
55 | 58 | {{- end -}} |
56 | 59 | {{- /* Ensure sharing_title is always set */ -}} |
|
67 | 70 | {{- range $shares -}} |
68 | 71 | {{- $share_str := "" -}} |
69 | 72 | {{- $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\"" -}} |
72 | 79 | {{- else -}} |
73 | 80 | {{- $twitter_share_val := index $current_item "share" -}} |
74 | 81 | {{- if $twitter_share_val -}} |
|
80 | 87 | {{- end -}} |
81 | 88 | {{- end -}} |
82 | 89 | {{- $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 -}} |
83 | 93 | {{- $.Scratch.Set "shares_js" $shares_js_str -}} |
84 | 94 |
|
85 | 95 | <script> |
|
88 | 98 |
|
89 | 99 | $(document).ready(function () { |
90 | 100 | //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 -}} |
92 | 105 | $("#share").jsSocials({ |
93 | | - shares: [{{ $.Scratch.Get "shares_js" }}], |
| 106 | + shares: [{{ $shares_js_final }}], |
94 | 107 | text: '{{ ($.Scratch.Get "sharing_title") }}', |
95 | 108 | showLabel: false, |
96 | 109 | showCount: false |
|
0 commit comments