@bbki.ng/site 5.1.4 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbki.ng/site",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "code behind bbki.ng",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"sonner": "1.4.0",
|
|
21
21
|
"swr": "^2.2.5",
|
|
22
22
|
"vaul": "1.1.2",
|
|
23
|
-
"@bbki.ng/components": "5.
|
|
24
|
-
"@bbki.ng/stylebase": "3.0
|
|
23
|
+
"@bbki.ng/components": "5.2.0",
|
|
24
|
+
"@bbki.ng/stylebase": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@mdx-js/mdx": "2.0.0-next.9",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vite-plugin-mdx": "^3.5.8",
|
|
60
60
|
"vite-plugin-pwa": "0.19",
|
|
61
61
|
"workbox-window": "^6.3.0",
|
|
62
|
-
"@bbki.ng/stylebase": "3.0
|
|
62
|
+
"@bbki.ng/stylebase": "3.1.0"
|
|
63
63
|
},
|
|
64
64
|
"author": "bbbottle",
|
|
65
65
|
"license": "MIT",
|
|
@@ -4,6 +4,7 @@ import { ROUTES } from "@/constants";
|
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import { Reaction } from "../reaction/oh_reaction";
|
|
6
6
|
import { useNavigate } from "react-router-dom";
|
|
7
|
+
import { ShareBtn } from "../share/share-btn";
|
|
7
8
|
|
|
8
9
|
export type ArticlePageProps = {
|
|
9
10
|
tags?: string[];
|
|
@@ -43,7 +44,7 @@ export const ArticlePage = (props: ArticlePageProps) => {
|
|
|
43
44
|
<article className={articleCls}>{props.children}</article>
|
|
44
45
|
<div className="relative left-[-4px]">
|
|
45
46
|
{allTags.length ? <Tags tags={allTags} className="mb-32" /> : null}
|
|
46
|
-
<Reaction title={title} />
|
|
47
|
+
<Reaction title={title} url={window.location.href} />
|
|
47
48
|
</div>
|
|
48
49
|
</Article>
|
|
49
50
|
<div className="">
|
|
@@ -8,6 +8,7 @@ import React, {
|
|
|
8
8
|
import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
|
|
9
9
|
import { BlinkDot } from "@bbki.ng/components";
|
|
10
10
|
import { faces, hearts, ReactionEmojiPair, sadFaces } from "./emojis";
|
|
11
|
+
import { ShareBtn } from "../share/share-btn";
|
|
11
12
|
|
|
12
13
|
declare global {
|
|
13
14
|
namespace JSX {
|
|
@@ -86,12 +87,19 @@ export const OpenHeartReaction = (props: {
|
|
|
86
87
|
);
|
|
87
88
|
};
|
|
88
89
|
|
|
89
|
-
export const Reaction = (props: { title: string }) => {
|
|
90
|
+
export const Reaction = (props: { title: string; url: string }) => {
|
|
90
91
|
return (
|
|
91
92
|
<div>
|
|
92
93
|
<OpenHeartReaction title={props.title} emojiPair={hearts} />
|
|
93
94
|
<OpenHeartReaction title={props.title} emojiPair={faces} />
|
|
94
95
|
<OpenHeartReaction title={props.title} emojiPair={sadFaces} />
|
|
96
|
+
|
|
97
|
+
<ShareBtn
|
|
98
|
+
shareInfo={{
|
|
99
|
+
title: props.title,
|
|
100
|
+
url: props.url,
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
95
103
|
</div>
|
|
96
104
|
);
|
|
97
105
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, ButtonType } from "@bbki.ng/components";
|
|
3
|
+
import { ShareIcon } from "./share-icon";
|
|
4
|
+
import { toast } from "sonner";
|
|
5
|
+
|
|
6
|
+
export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
|
|
7
|
+
const handleShare = async () => {
|
|
8
|
+
try {
|
|
9
|
+
await navigator.share(shareInfo);
|
|
10
|
+
toast.success("已分享");
|
|
11
|
+
} catch (error) {
|
|
12
|
+
const isAbortError = (error as Error).name === "AbortError";
|
|
13
|
+
if (isAbortError) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toast.error((error as Error).message);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Button type={ButtonType.GHOST} onClick={handleShare}>
|
|
23
|
+
<ShareIcon />
|
|
24
|
+
</Button>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const ShareIcon = () => (
|
|
4
|
+
<svg
|
|
5
|
+
data-testid="geist-icon"
|
|
6
|
+
height="12"
|
|
7
|
+
stroke-linejoin="round"
|
|
8
|
+
// style="color:currentColor"
|
|
9
|
+
viewBox="0 0 16 16"
|
|
10
|
+
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
|
|
11
|
+
width="12"
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill-rule="evenodd"
|
|
15
|
+
clip-rule="evenodd"
|
|
16
|
+
d="M7.29289 1.39644C7.68342 1.00592 8.31658 1.00592 8.70711 1.39644L11.7803 4.46966L12.3107 4.99999L11.25 6.06065L10.7197 5.53032L8.75 3.56065V10.25V11H7.25V10.25V3.56065L5.28033 5.53032L4.75 6.06065L3.68934 4.99999L4.21967 4.46966L7.29289 1.39644ZM13.5 9.24999V13.5H2.5V9.24999V8.49999H1V9.24999V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.24999V8.49999H13.5V9.24999Z"
|
|
17
|
+
fill="currentColor"
|
|
18
|
+
></path>
|
|
19
|
+
</svg>
|
|
20
|
+
);
|