%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/pages/news/
Upload File :
Create Path :
Current File : //var/www/html/pages/news/index.js

import Image from "next/image";
import Link from "next/link";
import { NewsBg } from "../../src/Components/Backgrounds";
import { ArrowRight } from "../../src/Components/Icons";
import Contact from "../../src/Components/Contact";
import parse from "html-react-parser";
import CustomHead from "../../src/Components/Global/CustomHead";

function NewsFeed({ data, seo }) {
  return (
    <>
      <CustomHead data={seo} />
      <div className="mainNewsFeed">
        <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>{data?.small_title}</h4>
          </div>
          <>{parse(data?.title)}</>
        </div>
        <div className="feedContent">
          {data?.posts.map((post, index) => {
            return (
              <div key={index} className="card">
                <Link href={`/news/${post.slug}`} passHref>
                  <a>
                    <Image
                      src={post.image}
                      alt=""
                      width="504"
                      height="530"
                      objectFit="cover"
                    />
                  </a>
                </Link>
                <span>{post.date}</span>

                <Link href={`/news/${post.slug}`} passHref>
                  <a>
                    <h4>{parse(post.title)}</h4>
                  </a>
                </Link>
                <Link href={`/news/${post.slug}`}>
                  <a>
                    Read More <ArrowRight />
                  </a>
                </Link>
              </div>
            );
          })}
        </div>
        <Contact />
      </div>
    </>
  );
}

export default NewsFeed;

export async function getServerSideProps(ctx) {
  const res = await fetch(
    `https://api.atvbuggy-dubrovnik.com/wp-json/api/v1/news`
  )
    .then((response) => response.json())
    .then((data) => data);

  const seo = await fetch(
    `https://api.atvbuggy-dubrovnik.com/wp-json/wp/v2/pages?slug=news`
  )
    .then((response) => response.json())
    .then((data) => data[0]);

  if (!res) {
    return {
      notFound: true,
    };
  }

  return {
    props: {
      data: res,
      seo: seo.yoast_head_json,
    },
  };
}

Zerion Mini Shell 1.0