/* eslint-disable */ import type { GetStaticPaths, InferGetStaticPropsType } from 'next'; import Head from "next/head"; import Image from "next/image"; type BlogPostAttributes = { imageUrl: string; title: string; description: string; draft: string; }; type BlogPost = { id: string; attributes: BlogPostAttributes; }; export const getStaticPaths: GetStaticPaths = async () => { try { const response = await fetch("https://cms.quivr.app/api/blogs"); if (!response.ok) { throw new Error('Network response was not ok'); // Handle non-200 responses } const data: { data: BlogPost[] } = await response.json(); const paths = data.data.map(post => ({ params: { id: post.id.toString() } })); return { paths, fallback: false, // Use "true" to enable ISR (Incremental Static Regeneration) or "blocking" for server-side rendering fallback }; } catch (error) { console.error("Error fetching blog paths:", error); return { paths: [], // Return empty array if there's an error fallback: false, // Use "true" to enable ISR or "blocking" for server-side rendering fallback }; } }; export const getStaticProps = async (context: { params: { id: string } }) => { try { const response = await fetch(`https://cms.quivr.app/api/blogs/${context.params.id}`); console.log(response) const data: { data: BlogPost } = await response.json(); return { props: { post: data.data, }, }; } catch (error) { console.error("Error fetching blog post:", error); return { notFound: true, }; } }; const BlogPostDetail = ({ post }: InferGetStaticPropsType) => { return (
{post.attributes.title}
blog-post-detail

{post.attributes.title}

{post.attributes.draft}

); } export default BlogPostDetail;