Skip to content

Commit 4d89fad

Browse files
committed
add share
1 parent cb0610b commit 4d89fad

File tree

12 files changed

+170
-0
lines changed

12 files changed

+170
-0
lines changed

public/share/fonts/iconfont.eot

9.36 KB
Binary file not shown.

public/share/fonts/iconfont.svg

Lines changed: 88 additions & 0 deletions
Loading

public/share/fonts/iconfont.ttf

9.08 KB
Binary file not shown.

public/share/fonts/iconfont.woff

6.21 KB
Binary file not shown.

public/share/share.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/share/social-share.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
import { getLangFromUrl, useTranslations } from "@/i18n";
3+
4+
interface Props {
5+
title?: string;
6+
url?: string;
7+
description?: string;
8+
image?: string;
9+
}
10+
11+
const { title, url, description, image } = Astro.props;
12+
const currentLang = getLangFromUrl(Astro.url);
13+
const t = useTranslations(currentLang);
14+
---
15+
16+
<div
17+
class="social-share share-component"
18+
data-sites="weibo,qq,wechat,douban,qzone,twitter,facebook"
19+
data-mobile-sites="weibo,qq,wechat,douban,qzone"
20+
data-disabled="google"
21+
data-wechat-qrcode-title={t('share.wechatTitle') || '微信扫一扫:分享'}
22+
data-wechat-qrcode-helper={t('share.wechatHelper') || '<p>微信里点"发现",扫一下二维码便可将本文分享至朋友圈。</p>'}
23+
data-title={title}
24+
data-url={url}
25+
data-description={description}
26+
data-image={image}
27+
>
28+
<span class="share-label text-neutral-600 dark:text-neutral-400 mr-2">{t('share.label') || '分享到'}:</span>
29+
</div>
30+
31+
<style is:global>
32+
.social-share .share-label {
33+
font-family: inherit !important;
34+
font-size: 14px;
35+
}
36+
37+
/* 暗色模式适配 */
38+
:root.dark .social-share .icon-wechat .wechat-qrcode {
39+
background-color: #1f1f1f;
40+
border-color: #333;
41+
color: #ccc;
42+
}
43+
44+
:root.dark .social-share .icon-wechat .wechat-qrcode h4 {
45+
background-color: #2a2a2a;
46+
color: #aaa;
47+
}
48+
49+
:root.dark .social-share .icon-wechat .wechat-qrcode:after {
50+
border-color: #1f1f1f transparent transparent transparent;
51+
}
52+
</style>

src/i18n/translations/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@
8585
"zh": "中文",
8686
"en": "English",
8787
"ja": "日本語"
88+
},
89+
"share": {
90+
"label": "Share",
91+
"wechatTitle": "Scan to Share via WeChat",
92+
"wechatHelper": "<p>Open WeChat, tap \"Discover\", and scan the QR code to share.</p>"
8893
}
8994
}

src/i18n/translations/ja.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@
8585
"zh": "中文",
8686
"en": "English",
8787
"ja": "日本語"
88+
},
89+
"share": {
90+
"label": "シェア",
91+
"wechatTitle": "WeChatでスキャンして共有",
92+
"wechatHelper": "<p>WeChatを開き、「発見」をタップしてQRコードをスキャンしてください。</p>"
8893
}
8994
}

src/i18n/translations/zh.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,10 @@
8585
"zh": "中文",
8686
"en": "English",
8787
"ja": "日本語"
88+
},
89+
"share": {
90+
"label": "分享到",
91+
"wechatTitle": "微信扫一扫:分享",
92+
"wechatHelper": "<p>微信里点\"发现\",扫一下二维码便可将本文分享至朋友圈。</p>"
8893
}
8994
}

0 commit comments

Comments
 (0)