You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2022/04/26 06:54:53 UTC

[apisix-website] branch master updated: refactor: summit link poster card (#1058)

This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d2dcf52f33 refactor: summit link poster card (#1058)
0d2dcf52f33 is described below

commit 0d2dcf52f33efacafac140a25ce6b1315191be5e
Author: Young <is...@outlook.com>
AuthorDate: Tue Apr 26 14:54:50 2022 +0800

    refactor: summit link poster card (#1058)
---
 .../pages/sections/components/EventPosterCard.tsx  | 35 +++++++++++++---------
 website/static/data/event-poster-card.json         |  7 +++--
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/website/src/pages/sections/components/EventPosterCard.tsx b/website/src/pages/sections/components/EventPosterCard.tsx
index f063a37ce2c..6f592d981fd 100644
--- a/website/src/pages/sections/components/EventPosterCard.tsx
+++ b/website/src/pages/sections/components/EventPosterCard.tsx
@@ -9,16 +9,20 @@ interface EventPosterCardInfo {
   show: boolean;
   expire: string;
   image: string;
-  link: string;
+  links: { [key: string]: string };
 }
 
+const LANG_STOR_KEY = 'localLang';
+const SHOW_STORE_KEY = 'SHOW_EVENT_ENTRY';
+
 const EventPosterCard:FC = () => {
   const { siteConfig } = useDocusaurusContext();
   const {
-    show, expire, link, image,
+    show, expire, links, image,
   } = siteConfig.customFields.eventPosterCard as EventPosterCardInfo;
   const [display, setDisplay] = useState(false);
   const picRef = useRef(null);
+  const [link, setLink] = useState<string>('');
 
   useEffect(() => {
     gsap.fromTo(picRef.current, {
@@ -32,16 +36,19 @@ const EventPosterCard:FC = () => {
   }, []);
 
   useEffect(() => {
-    if (!localStorage.getItem('SHOW_EVENT_ENTRY')) {
-      setDisplay(true);
-    }
+    if (typeof window === 'undefined') return;
+    const lang = localStorage.getItem(LANG_STOR_KEY);
+    setLink(links[lang]);
+  }, []);
 
-    if (!show) {
-      setDisplay(false);
-    } else {
+  useEffect(() => {
+    if (show) {
       const expireTimestamp = new Date(expire).getTime();
-      if (expireTimestamp <= new Date().getTime()) {
-        setDisplay(false);
+      if (
+        !sessionStorage.getItem(SHOW_STORE_KEY)
+         && (expireTimestamp > new Date().getTime())
+      ) {
+        setDisplay(true);
       }
     }
   }, []);
@@ -54,9 +61,9 @@ const EventPosterCard:FC = () => {
         setDisplay(false);
       },
     });
-    if (typeof window !== 'undefined') {
-      localStorage.setItem('SHOW_EVENT_ENTRY', 'true');
-    }
+
+    if (typeof window === 'undefined') return;
+    sessionStorage.setItem(SHOW_STORE_KEY, 'true');
   };
 
   if (!display) {
@@ -79,7 +86,7 @@ const EventPosterCard:FC = () => {
           <path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" />
         </svg>
       </button>
-      <a href={link} onClick={onClose}>
+      <a href={link} onClick={onClose} target="_blank" rel="noreferrer">
         <img src={image} alt="" />
       </a>
     </div>
diff --git a/website/static/data/event-poster-card.json b/website/static/data/event-poster-card.json
index ef0bca53757..354746dae9f 100644
--- a/website/static/data/event-poster-card.json
+++ b/website/static/data/event-poster-card.json
@@ -2,5 +2,8 @@
   "show": true,
   "expire": "2022-05-21",
   "image": "https://static.apiseven.com/202108/1649729812376-b05269c8-90b9-4d73-b97e-463beb351d1d.png",
-  "link": "/blog/2022/04/12/apisix-summit-asia-2022"
-}
+  "links": {
+    "en": "https://apisix-summit.org",
+    "zh": "http://hdxu.cn/vcGn3"
+  }
+}
\ No newline at end of file