/* eslint-disable */ /* https://strapi.io/blog/how-to-create-an-ssg-static-site-generation-application-with-strapi-webhooks-and-nextjs */ import type { InferGetStaticPropsType } from 'next'; import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; import "@/globals.css"; type BlogPostAttributes = { imageUrl: string; title: string; description: string; slug: string; publishedAt: string; seo: { metaTitle: string; metaDescription: string; metaImage: { data: { attributes: { formats: { medium: { url: string; }; }; }; }; }; }; }; type BlogPost = { id: string; attributes: BlogPostAttributes; }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export const getStaticProps = async () => { try { const resulting = await fetch("https://cms.quivr.app/api/blogs?populate=seo,seo.metaImage,slug"); const data: { data: BlogPost[] } = await resulting.json(); // Sort blogs by publishedAt in descending order const sortedBlogs = data.data.sort((a, b) => new Date(b.attributes.publishedAt).getTime() - new Date(a.attributes.publishedAt).getTime()); return { props: { result: sortedBlogs, }, }; } catch (error) { console.error("Error fetching blogs:", error); return { notFound: true, // this will return a 404 page }; } }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types const Blog = ({ result }: InferGetStaticPropsType) => { return (
Quivr - Blog
{result.map(post => (
Blog Post Image

{post.attributes.seo.metaTitle}

{post.attributes.seo.metaDescription}

Read More
))}
); } export default Blog;