diff options
author | haya14busa <hayabusa1419@gmail.com> | 2020-12-31 09:38:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-31 09:38:34 +0300 |
commit | b7a48306996c62081ceb14da88e7e114ae57397d (patch) | |
tree | 5fa257f8ec0c04062b7d950810b20e066a32555c | |
parent | 00e5ae0b2fe82c7d68aeb524447982afcea625b6 (diff) |
User Config to Enable/Disable Share Services (#20)
-rwxr-xr-x | data/services.toml | 1 | ||||
-rw-r--r-- | layouts/partials/share.html | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/data/services.toml b/data/services.toml new file mode 100755 index 0000000..70b6df1 --- /dev/null +++ b/data/services.toml @@ -0,0 +1 @@ +share = ["facebook", "twitter"] diff --git a/layouts/partials/share.html b/layouts/partials/share.html index 35f97f2..0c347cb 100644 --- a/layouts/partials/share.html +++ b/layouts/partials/share.html @@ -1,7 +1,20 @@ +{{- $currentPage := . -}} {{- $author := partial "author-data" . -}} {{- $twitterSVG := partial "svg/twitter.svg" (dict "class" "w-6 h-6 fill-current") -}} {{- $facebookSVG := partial "svg/facebook.svg" (dict "class" "w-6 h-6 fill-current" "viewbox" "-7 -3.5 39 39") -}} +{{- $facebookApp := .Site.Params.services.facebookApp -}} +{{- $share := .Site.Data.services.share -}} +{{- /* Use isset instead of default to support explicit empty array */ -}} +{{- if isset .Site.Params.share "enable" -}} + {{- $share = .Site.Params.share.enable -}} +{{- end -}} +{{- with $share -}} <div class="flex items-center"> - <a class="flex-shrink-0 block text-raven-800 hover:text-raven-900" target="_blank" rel="noopener nofollow" title="{{ (T "twitterShare" .) }}" href="https://twitter.com/intent/tweet?text={{ printf "%s by @%s %s" .Title $author.twitter .Permalink }}">{{ $twitterSVG }}</a> - <a class="ml-3 flex-shrink-0 block text-raven-800 hover:text-raven-900" target="_blank" rel="noopener nofollow" title="{{ (T "facebookShare" .) }}" href="https://www.facebook.com/dialog/share?app_id={{ .Site.Params.services.facebookApp }}&display=page&href={{ .Permalink }}">{{ $facebookSVG }}</a> + {{- if in $share "twitter" }} + <a class="flex-shrink-0 block text-raven-800 hover:text-raven-900" target="_blank" rel="noopener nofollow" title="{{ (T "twitterShare" $currentPage) }}" href="https://twitter.com/intent/tweet?text={{ printf "%s by @%s %s" $currentPage.Title $author.twitter $currentPage.Permalink }}">{{ $twitterSVG }}</a> + {{- end }} + {{- if in $share "facebook" }} + <a class="ml-3 flex-shrink-0 block text-raven-800 hover:text-raven-900" target="_blank" rel="noopener nofollow" title="{{ (T "facebookShare" $currentPage) }}" href="https://www.facebook.com/dialog/share?app_id={{ $facebookApp }}&display=page&href={{ $currentPage.Permalink }}">{{ $facebookSVG }}</a> + {{- end }} </div> +{{- end -}} |