Skip to content

Commit

Permalink
feat: add support for email, Reddit, Telegram and WhatsApp (#25)
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
razonyang authored Mar 14, 2024
1 parent 54114d7 commit 844db8e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
15 changes: 15 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
[social_share_button_email]
other = "Email"

[social_share_button_facebook]
other = "Facebook"

[social_share_button_linkedin]
other = "LinkedIn"

[social_share_button_reddit]
other = "Reddit"

[social_share_button_sinaweibo]
other = "Sina Weibo"

[social_share_button_telegram]
other = "Telegram"

[social_share_button_twitter]
other = "Twitter"

[social_share_button_whatsapp]
other = "WhatsApp"

[social_share_subject]
other = "I'd like to share a link with you"
15 changes: 15 additions & 0 deletions i18n/zh-hans.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
[social_share_button_email]
other = "邮件"

[social_share_button_facebook]
other = "脸书"

[social_share_button_linkedin]
other = "领英"

[social_share_button_reddit]
other = "Reddit"

[social_share_button_sinaweibo]
other = "微博"

[social_share_button_telegram]
other = "Telegram"

[social_share_button_twitter]
other = "推特"

[social_share_button_whatsapp]
other = "WhatsApp"

[social_share_subject]
other = "我想和你分享一个链接"
15 changes: 15 additions & 0 deletions i18n/zh-hant.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
[social_share_button_email]
other = "郵件"

[social_share_button_facebook]
other = "臉書"

[social_share_button_linkedin]
other = "領英"

[social_share_button_reddit]
other = "Reddit"

[social_share_button_sinaweibo]
other = "微博"

[social_share_button_telegram]
other = "Telegram"

[social_share_button_twitter]
other = "推特"

[social_share_button_whatsapp]
other = "WhatsApp"

[social_share_subject]
other = "我想和你分享一個鏈接"
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
{{- $icons := default true $params.icons }}
{{- $labels := default true $params.labels }}
{{- $size := default "1.25em" $params.size }}
{{- $subject := i18n "social_share_subject" }}
{{- $media := partialCached "hb/modules/social-share-buttons/functions/media" . }}
{{- range default slice $params.media }}
{{- $name := . }}
{{- $label := default (title $name) (printf "social_share_button_%s" $name | i18n) }}
{{- with index $media $name }}
{{- $url := replace .url "{url}" (urlquery $page.Permalink) 1 }}
{{- $url = replace $url "{text}" (urlquery $page.Title) 1 }}
{{- $url = replace $url "{title}" $page.Title 1 }}
{{- $url = replace $url "{subject}" $subject 1 }}
<a
class="hb-social-share-button hb-social-share-button-{{ $name }} text-decoration-none d-flex align-items-center"
target="_blank"
title="{{ $label }}"
href="{{ $url }}">
{{- if $icons }}
{{- $icon := dict
"vendor" "simple"
"vendor" (default "simple" .iconVendor)
"name" (default $name .icon)
"width" $size
"height" $size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{{- $media := dict
"email" (dict
"url" "mailto:?subject={subject}&body={text} {url}"
"icon" "envelope"
"iconVendor" "bs"
)
"facebook" (dict
"url" "https://www.facebook.com/sharer/sharer.php?u={url}"
"iconColor" "#0866FF"
Expand All @@ -7,14 +12,26 @@
"url" "https://www.linkedin.com/sharing/share-offsite/?url={url}"
"iconColor" "#0A66C2"
)
"reddit" (dict
"url" "https://www.reddit.com/submit?title={text}&url={url}"
"iconColor" "#FF4500"
)
"sinaweibo" (dict
"url" "https://service.weibo.com/share/share.php?url={url}&title={text}"
"iconColor" "#E6162D"
)
"telegram" (dict
"url" "https://t.me/share/url?url={url}&text={text}"
"iconColor" "#26A5E4"
)
"twitter" (dict
"url" "https://twitter.com/intent/tweet?url={url}&text={text}"
"icon" "x"
"iconColor" "#000000"
)
"sinaweibo" (dict
"url" "https://service.weibo.com/share/share.php?url={url}&title={text}"
"iconColor" "#E6162D"
"whatsapp" (dict
"url" "https://wa.me/?text={url} {title}"
"iconColor" "#25D366"
)
}}
{{- return $media }}

0 comments on commit 844db8e

Please sign in to comment.