// app/news-details/[slug]/page.jsx

import BlogDetails from "@/components/blogs/BlogDetails";
import Footer1 from "@/components/footers/Footer1";
import Header1 from "@/components/headers/Header1";
import { allBlogs } from "@/utlis/constant.utils";
import Image from "next/image";
import Link from "next/link";
import { notFound } from "next/navigation";

export const metadata = {
  title: "Blog Details || Xbuild - Construction Next.js Template",
  description: "Xbuild - Construction Next.js Template",
};

export async function generateStaticParams() {
  return allBlogs.map((item) => ({ slug: item.slug }));
}

export default function Page({ params }) {
  const newsItem = allBlogs.find((elm) => elm.slug === params.slug);

  if (!newsItem) {
    notFound(); // Show 404 if not found
  }

  return (
    <>
      <Header1 />
      <div
        className="breadcrumb-wrapper bg-cover"
        style={{ backgroundImage: `url(${newsItem.bannerImage})` }}
      >
        <div className="container">
          <div className="breadcrumb-wrapper-items">
            <div className="page-heading">
              <div className="breadcrumb-sub-title">
                <h1 className="wow fadeInUp" data-wow-delay=".3s">
                  {newsItem.title}
                </h1>
              </div>
              <ul
                className="breadcrumb-items wow fadeInUp"
                data-wow-delay=".5s"
              >
                <li>
                  <Link href={`/`}> Home </Link>
                </li>
                <li>
                  <i className="fa-sharp fa-solid fa-slash-forward" />
                </li>
                <li>{newsItem.title}</li>
              </ul>
            </div>
            <div className="breadcrumb-image" />
          </div>
        </div>
      </div>
      <BlogDetails newsItem={newsItem} />
      {/* <div className="brand-section fix section-padding pt-0">
        <Brands />
      </div> */}
      <Footer1 />
    </>
  );
}
