diff --git a/components/landing-page/hero-new.tsx b/components/landing-page/hero-new.tsx index c08a9ca0..90b71e2b 100644 --- a/components/landing-page/hero-new.tsx +++ b/components/landing-page/hero-new.tsx @@ -437,6 +437,18 @@ const HeroNew = (props: { group?: string }) => { ? Buffer.from(str).toString("base64") : window.btoa(str); + const [scrollIndex, setScrollIndex] = useState(0); + + useEffect(() => { + if (!content || content.length < 3) return; + + const interval = setInterval(() => { + setScrollIndex((prevIndex) => (prevIndex + 1) % content.length); + }, 3000); + + return () => clearInterval(interval); + }, [content]); + return (
@@ -509,122 +521,142 @@ const HeroNew = (props: { group?: string }) => { */}
- - {content?.map((list: any) => ( - -
- {/* Gambar */} - gambar + {content && content.length > 0 && ( + + {content.map((list: any) => ( + +
+ {/* Gambar */} + gambar - {/* Overlay hitam transparan */} -
+ {/* Overlay */} +
- {/* Konten judul */} - - - {list?.categoryName} - -

{list?.title}

-

- {formatDateToIndonesian(new Date(list?.createdAt))}{" "} - {list?.timezone || "WIB"} | 👁 {list?.clickCount} -

- + {/* Judul & Link */} + + + {list?.categoryName} + +

{list?.title}

+

+ {formatDateToIndonesian(new Date(list?.createdAt))}{" "} + {list?.timezone || "WIB"} | 👁 {list?.clickCount} +

+ - {/* Tombol navigasi */} -
- + {/* Tombol navigasi */} +
+ +
+
+ +
-
- -
-
- - ))} - + + ))} + + )}
-
- {newContent?.slice(0, 3).map((item: any) => ( -
  • -
    - {item?.title} -
    -
    - -

    - {item?.categoryName} -

    -

    - {item?.title} -

    -

    - {formatDateToIndonesian(new Date(item?.createdAt))}{" "} - {item?.timezone || "WIB"} |{" "} - - +

    + {content?.length >= 2 && + [0, 1].map((offset) => { + const item = content[(scrollIndex + offset) % content.length]; + return ( +
  • +
    + {item?.title} - {" "} - {item?.clickCount} -

    - -
    -
  • - ))} +
    +
    + +

    + {item?.categoryName} +

    +

    + {item?.title} +

    +

    + {formatDateToIndonesian(new Date(item?.createdAt))}{" "} + {item?.timezone || "WIB"} |{" "} + + + {" "} + {item?.clickCount} +

    + +
    + + ); + })} +
    )}