Skip to content

Commit 1cde3dd

Browse files
author
qi_xing_jk
committed
feat(增强分享按钮的tags功能): 给Facebook/Twitter/Tumblr和Workplace 添加分享按钮的tags功能
1 parent ce94ca9 commit 1cde3dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/ShareButtons.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const ShareButtons = ({ post }) => {
6262
const shareUrl = siteConfig('LINK') + router.asPath
6363
const title = post.title || siteConfig('TITLE')
6464
const image = post.pageCover
65+
const tags = post.tags || []
66+
const hashTags = tags.map(tag => `#${tag}`).join(',')
6567
const body = post?.title + ' | ' + title + ' ' + shareUrl + ' ' + post?.summary
6668

6769
const services = siteConfig('POSTS_SHARE_SERVICES').split(',')
@@ -89,6 +91,7 @@ const ShareButtons = ({ post }) => {
8991
<FacebookShareButton
9092
key={singleService}
9193
url={shareUrl}
94+
hashtag={hashTags}
9295
className="mx-1"
9396
>
9497
<FacebookIcon size={32} round />
@@ -151,6 +154,7 @@ const ShareButtons = ({ post }) => {
151154
key={singleService}
152155
url={shareUrl}
153156
title={titleWithSiteInfo}
157+
hashtags={tags}
154158
className="mx-1"
155159
>
156160
<TwitterIcon size={32} round />
@@ -235,6 +239,7 @@ const ShareButtons = ({ post }) => {
235239
key={singleService}
236240
url={shareUrl}
237241
title={titleWithSiteInfo}
242+
tags={tags}
238243
className="mx-1"
239244
>
240245
<TumblrIcon size={32} round />
@@ -284,6 +289,7 @@ const ShareButtons = ({ post }) => {
284289
key={singleService}
285290
url={shareUrl}
286291
quote={titleWithSiteInfo}
292+
hashtag={hashTags}
287293
className="mx-1"
288294
>
289295
<WorkplaceIcon size={32} round />

0 commit comments

Comments
 (0)