Unlock seamless workflows and faster delivery with our latest releases – get the details

Issue with post body not showing in a blog website created using Sanity+Next template.

5 replies
Last updated: Apr 17, 2024
Hey everyone, I am new to Sanity and trying to create a blog website using Sanity+Next. I am using this template . The blog is building fine but the post body is not showing (Title, author, etc show up fine). Can someone help?
Apr 17, 2024, 4:55 PM
my queries file looks like this:
import { groq } from "next-sanity";

export const settingsQuery = groq`*[_type == "settings"][0]`;

const postFields = /* groq */ `
  _id,
  "status": select(_originalId in path("drafts.**") => "draft", "published"),
  "title": coalesce(title, "Untitled"),
  "slug": slug.current,
  excerpt,
  coverImage,
  "date": coalesce(date, _updatedAt),
  "author": author->{"name": coalesce(name, "Anonymous"), picture},
`;

export const heroQuery = groq`*[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] {
  content,
  ${postFields}
}`;

export const moreStoriesQuery = groq`*[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {
  ${postFields}
}`;

export const postQuery = groq`*[_type == "post" && slug.current == $slug] [0] {
  content,
  ${postFields}
}`;
Apr 17, 2024, 4:56 PM
Are you getting no data from your queries or are some fields just missing?
Apr 17, 2024, 5:34 PM
Some fields were missing. figured it out. The query needed the
body
parameter while I can looking for
content
Apr 17, 2024, 5:43 PM
All good now. thanks
Apr 17, 2024, 5:43 PM
Excellent!
Apr 17, 2024, 5:48 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?