@bbki.ng/site 1.2.0 → 1.2.1
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": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "code behind bbki.ng",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react-hotkeys-hook": "^3.4.3",
|
|
26
26
|
"react-router-dom": "6",
|
|
27
27
|
"sonner": "1.4.0",
|
|
28
|
-
"swr": "^2.2.
|
|
28
|
+
"swr": "^2.2.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@bbki.ng/stylebase": "workspace:0.1.0",
|
package/src/hooks/use_post.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { API } from "@/constants/routes";
|
|
3
3
|
import { useAuthedFetcher } from "@/hooks/use_authed_fetcher";
|
|
4
|
-
import useSWRMutation from "swr/mutation";
|
|
5
4
|
|
|
6
5
|
export const usePost = () => {
|
|
7
6
|
const authedFetcher = useAuthedFetcher();
|
|
@@ -19,7 +18,9 @@ export const usePost = () => {
|
|
|
19
18
|
[authedFetcher]
|
|
20
19
|
);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return useCallback(
|
|
22
|
+
(title: string, content: string) =>
|
|
23
|
+
req(API.POSTS, { arg: { title, content } }),
|
|
24
|
+
[req]
|
|
25
|
+
);
|
|
25
26
|
};
|
|
@@ -26,7 +26,9 @@ export const useProjects = (name: string = "", suspense?: boolean) => {
|
|
|
26
26
|
if (!n) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
return cache
|
|
29
|
+
return cache
|
|
30
|
+
.get("projects")
|
|
31
|
+
?.data.find((p: { name: string }) => p.name === n);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
const refresh = useCallback(() => {
|
package/src/utils/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { Photo } from "@/types/photo";
|
|
|
2
2
|
import { ossProcessType } from "@/types/oss";
|
|
3
3
|
import { API_ENDPOINT, OSS_ADDRESS } from "@/constants/routes";
|
|
4
4
|
import { DEFAULT_DELAY } from "@/constants";
|
|
5
|
-
import useSWR
|
|
5
|
+
import useSWR from "swr";
|
|
6
|
+
|
|
7
|
+
type Fetcher = (resource: string, init?: any) => Promise<any>;
|
|
6
8
|
|
|
7
9
|
export const floatNumberToPercentageString = (num: number): string => {
|
|
8
10
|
return `${num * 100}%`;
|
|
@@ -96,7 +98,7 @@ export const withToken =
|
|
|
96
98
|
};
|
|
97
99
|
|
|
98
100
|
export const withBBApi =
|
|
99
|
-
(fetcher: Fetcher
|
|
101
|
+
(fetcher: Fetcher) =>
|
|
100
102
|
(apiEndPoint = API_ENDPOINT): Fetcher =>
|
|
101
103
|
async (resource: string, init: RequestInit = {}) =>
|
|
102
104
|
fetcher(`${apiEndPoint}/${resource}`, { ...init, mode: "cors" });
|