Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marketempower/axiom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaya14busa <hayabusa1419@gmail.com>2020-12-31 09:38:34 +0300
committerGitHub <noreply@github.com>2020-12-31 09:38:34 +0300
commitb7a48306996c62081ceb14da88e7e114ae57397d (patch)
tree5fa257f8ec0c04062b7d950810b20e066a32555c
parent00e5ae0b2fe82c7d68aeb524447982afcea625b6 (diff)
User Config to Enable/Disable Share Services (#20)
-rwxr-xr-xdata/services.toml1
-rw-r--r--layouts/partials/share.html17
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 -}}