import BlogPage from "@/components/blog";
import Layout from "@/components/layout/StLayout";
import { fetchReq } from "@/lib/req";

async function Blog({ params: { slug } }) {
  const API_URL = process.env.NEXT_PUBLIC_API_URL;

  const blog = await fetchReq(`${API_URL}/api/v1/blog/${slug}`);
  const blogs = await fetchReq(`${API_URL}/api/v1/blogs`);

  return (
    <Layout>
      <BlogPage blog={blog} blogs={blogs.blogs} />
    </Layout>
  );
}

export default Blog;
