From 1e46040d9398d30cdc0883ad831f355f73981a2f Mon Sep 17 00:00:00 2001 From: vaporvee Date: Wed, 30 Oct 2024 03:28:09 +0100 Subject: [PATCH] fixed visual editing again --- src/app/blog/page.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx index e8708ab..19698db 100644 --- a/src/app/blog/page.tsx +++ b/src/app/blog/page.tsx @@ -1,28 +1,26 @@ import Link from "next/link"; import { type SanityDocument } from "next-sanity"; -import { client } from "@/sanity/client"; +import { client, sanityFetch } from "@/sanity/client"; +import { Post } from "@/sanity/sanity.types"; const POSTS_QUERY = `*[ _type == "post" && defined(slug.current) ]|order(publishedAt desc)[0...12]{_id, title, slug, publishedAt}`; -const options = { next: { revalidate: 30 } }; - export default async function IndexPage() { - const posts = await client.fetch(POSTS_QUERY, {}, options); - + const posts = (await sanityFetch({ query: POSTS_QUERY, perspective: "published" })).data; return (
Home

Blog

    - {posts.map((post) => ( + {posts.map((post: Post) => (
  • - +

    {post.title}

    -

    {new Date(post.publishedAt).toLocaleDateString()}

    +

    {new Date(post.publishedAt ?? "").toLocaleDateString()}

  • ))}