@bbki.ng/site 2.0.18 → 2.0.19

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
@@ -1,5 +1,7 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 2.0.19
4
+
3
5
  ## 2.0.18
4
6
 
5
7
  ## 2.0.17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/blog/app.tsx CHANGED
@@ -27,6 +27,7 @@ import { BBContext } from "@/context/bbcontext";
27
27
  import { PluginContentPage } from "@/components/plugin/PluginContentPage";
28
28
  import { PluginRoutes } from "@/components/plugin/PluginRoutes";
29
29
  import {useClipboardToPost} from "@/hooks/use_clipboard_to_post";
30
+ import {useSharedStringToPost} from "@/hooks/use_shared_string_to_post";
30
31
 
31
32
  const Layout = () => {
32
33
  const { isLoading, isFontLoading } = useContext(GlobalLoadingContext);
@@ -55,7 +56,6 @@ const Layout = () => {
55
56
 
56
57
  const NowInMidCol = threeColWrapper(NowPage);
57
58
  const ContentInMidCol = threeColWrapper(Txt);
58
- const ProjectsInMidCol = threeColWrapper(Png);
59
59
  const ArticleInMidCol = threeColWrapper(ArticlePage);
60
60
  const TagsInMidCol = threeColWrapper(Tags);
61
61
  const LoginInMidCol = threeColWrapper(Login);
@@ -66,6 +66,8 @@ export const App = () => {
66
66
 
67
67
  useClipboardToPost();
68
68
 
69
+ useSharedStringToPost();
70
+
69
71
  return (
70
72
  <SWR>
71
73
  {/*<EffectContextProvider>*/}
@@ -0,0 +1,23 @@
1
+ import {useEffect} from "react";
2
+ import {useAuthedStringPost} from "@/hooks/use_authed_string_post";
3
+
4
+ export const useSharedStringToPost = () => {
5
+ const post = useAuthedStringPost();
6
+
7
+ useEffect(() => {
8
+ const handleSharedString = (event: MessageEvent) => {
9
+ if (event.data && typeof event.data === "string") {
10
+ const content = event.data;
11
+ if (content) {
12
+ post(content);
13
+ }
14
+ }
15
+ }
16
+
17
+ window.addEventListener("message", handleSharedString);
18
+
19
+ return () => {
20
+ window.removeEventListener("message", handleSharedString);
21
+ }
22
+ }, []);
23
+ }
package/vite.config.js CHANGED
@@ -84,6 +84,19 @@ export default defineConfig({
84
84
  },
85
85
  },
86
86
  },
87
+ {
88
+ urlPattern: /new-content-handler/,
89
+ method: "GET",
90
+ handler: ({ event, data }) => {
91
+ const url = new URL(event.request.url);
92
+ const sharedContent = url.searchParams.get("content");
93
+
94
+ // post the shared content to the main thread
95
+ if (sharedContent) {
96
+ window.postMessage(sharedContent, {})
97
+ }
98
+ },
99
+ },
87
100
  {
88
101
  urlPattern: /^https:\/\/fonts\.gstatic.com\.com\/.*/i,
89
102
  handler: "CacheFirst",
@@ -102,8 +115,15 @@ export default defineConfig({
102
115
  },
103
116
  manifest: {
104
117
  name: "bbki.ng",
105
- description: "words, pictures.",
118
+ description: "A personal blog.",
106
119
  theme_color: "#ffffff",
120
+ "share_target": {
121
+ "action": "/new-content-handler/",
122
+ "method": "GET",
123
+ "params": {
124
+ "text": "content",
125
+ }
126
+ },
107
127
  icons: [
108
128
  {
109
129
  src: "pwa-192x192.png",