@bbki.ng/site 1.2.17 → 1.2.18

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
+ ## 1.2.18
4
+
3
5
  ## 1.2.17
4
6
 
5
7
  ## 1.2.16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- import React, { ReactElement, useContext } from "react";
1
+ import React, { ReactElement, useContext, useEffect } from "react";
2
2
  import { MdxArticleList } from "@/articles";
3
3
  import { withArticleWrapper } from "@/components";
4
4
  import { MdxArticle } from "@/types/articles";
@@ -7,6 +7,9 @@ import { useParams } from "react-router-dom";
7
7
  import { usePosts } from "@/hooks/use_posts";
8
8
  import { ArticlePage } from "@/components/article";
9
9
  import { GlobalLoadingContext } from "@/global_loading_state_provider";
10
+ import { DropZone } from "@bbki.ng/components/lib";
11
+ import { useFile2Post } from "@/hooks/use_file_to_post";
12
+ import { useAuthed } from "@/hooks/use_authed";
10
13
 
11
14
  type TArticleMap = {
12
15
  [key: string]: ReactElement;
@@ -25,6 +28,14 @@ export default () => {
25
28
  const { posts, isError, isLoading } = usePosts(title);
26
29
  const { setIsLoading } = useContext(GlobalLoadingContext);
27
30
 
31
+ useEffect(() => {
32
+ // scroll to top
33
+ window.scrollTo(0, 0);
34
+ }, []);
35
+
36
+ const reader = useFile2Post();
37
+ const isKing = useAuthed();
38
+
28
39
  if (!title) {
29
40
  return <NotFound />;
30
41
  }
@@ -42,12 +53,11 @@ export default () => {
42
53
  return null;
43
54
  }
44
55
 
45
- // scroll to top
46
- window.scrollTo(0, 0);
47
-
48
56
  return (
49
- <ArticlePage title={title}>
50
- <div dangerouslySetInnerHTML={{ __html: posts.content }} />
51
- </ArticlePage>
57
+ <DropZone onDrop={reader} disabled={!isKing}>
58
+ <ArticlePage title={title}>
59
+ <div dangerouslySetInnerHTML={{ __html: posts.content }} />
60
+ </ArticlePage>
61
+ </DropZone>
52
62
  );
53
63
  };