import BlogDeatilSection from '@/app/components/BlogDeatil/BlogDeatilSection/BlogDeatilSection'
import H1 from '@/app/components/common/H1'
import H2 from '@/app/components/common/H2'
import H5 from '@/app/components/common/H5'
import { FlexBox, SiteBannerSection } from '@/app/components/common/HOC'
import getBlogdetail from '@/utils/ssrapi/getblogdetails'
import { notFound } from 'next/navigation'
import React from 'react'

const Blog = async ({ params }) => {
    const data = await getBlogdetail(params?.blogdetail)

    if (data?.data?.length<1) {
        return notFound()
    }
    return (
        <>
            <SiteBannerSection>
                <FlexBox className="title-group">
                    <H2 className="h1" text={'Blog'} />
                    <div className="bg-title-body">
                        <H2 className="bg-title" text={'Blog'} />
                    </div>
                    <H5
                        text={
                            'Stay ahead of the curve Stay up to date with healthcare'
                        }
                    />
                </FlexBox>
            </SiteBannerSection>
            <BlogDeatilSection data={data} />
        </>
    )
}
export async function generateMetadata({ params, searchParams }, parent) {
    // read route params
    const data = await getBlogdetail(params?.blogdetail)

    // fetch data

    // optionally access and extend (rather than replace) parent metadata
    // const previousImages = (await parent).openGraph?.images || []

    return {
        title: data?.data?.[0]?.blogTitle,
        canonical: `${process.env.NEXT_PUBLIC_BASE}/blog/${params?.blogdetail}`,
        // alternates: {
        //     canonical: `${process.env.NEXT_PUBLIC_BASE}/blog/${params?.blogdetail}`,
        //     languages: {
        //         'en-US': '/en-US',
        //         'de-DE': '/de-DE'
        //     }
        // },
        openGraph: {
            images: data?.data?.[0]?.image,
            title: data?.data?.[0]?.blogTitle,
            description: data?.data?.[0]?.conclusion,
            width:1200,
            height:630
        }
        // robots: {
        //     index: true,
        //     follow: true,
        //     nocache: true,
        //     googleBot: {
        //         index: true,
        //         follow: true,
        //         noimageindex: true,
        //         'max-video-preview': -1,
        //         'max-image-preview': 'large',
        //         'max-snippet': -1
        //     }
        // }
    }
}
export default Blog
