Add share_event JS function

This commit is contained in:
BBaoVanC 2022-05-01 18:14:02 -05:00
parent a172b1ea21
commit fa5c014a1b
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
3 changed files with 12 additions and 0 deletions

3
assets/js/share-event.js Normal file
View File

@ -0,0 +1,3 @@
function share_event(service) {
// this function does nothing by default
}

View File

@ -12,9 +12,13 @@
{{ with resources.Get "css/syntax-light.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ with resources.Get "js/back-to-top.js" | fingerprint "sha512" }}
<script defer src="{{ .Permalink }}" type="text/javascript" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ with resources.Get "js/share-event.js" | fingerprint "sha512" }}
<script defer src="{{ .Permalink }}" type="text/javascript" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ with .Site.Params.faviconSVG }}
<link rel="icon" href="{{ . | absURL }}" />

View File

@ -3,6 +3,7 @@
<a class="twitter-share"
target="_blank"
rel="noopener"
onclick="share_event('Twitter');"
href="https://twitter.com/intent/tweet?url={{ .Permalink }}&text={{ .Title }}&via=bbaovanc">
{{- partial "icon.html" "twitter" -}}
</a>
@ -12,6 +13,7 @@
<a class="facebook-share"
target="_blank"
rel="noopener"
onclick="share_event('Facebook');"
href="https://www.facebook.com/sharer.php?u={{ .Permalink }}">
{{- partial "icon.html" "facebook" -}}
</a>
@ -21,6 +23,7 @@
<a class="linkedin-share"
target="_blank"
rel="noopener"
onclick="share_event('LinkedIn');"
href="https://www.linkedin.com/sharing/share-offsite/?url={{ .Permalink }}">
{{- partial "icon.html" "linkedin" -}}
</a>
@ -30,6 +33,7 @@
<a class="reddit-share"
target="_blank"
rel="noopener"
onclick="share_event('Reddit');"
href="https://reddit.com/submit?url={{ .Permalink }}&title={{ .Title }}">
{{- partial "icon.html" "reddit" -}}
</a>
@ -42,6 +46,7 @@
<a class="telegram-share"
target="_blank"
rel="noopener"
onclick="share_event('Telegram');"
href="https://t.me/share/url?url={{ .Permalink }}&text={{ .Title }}">
{{- partial "icon.html" "telegram" -}}
</a>