mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
35 lines
915 B
TypeScript
35 lines
915 B
TypeScript
import { defineQuery } from "next-sanity";
|
|
|
|
export const settingsQuery = defineQuery(`*[_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 = defineQuery(`
|
|
*[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] {
|
|
content,
|
|
${postFields}
|
|
}
|
|
`);
|
|
|
|
export const moreStoriesQuery = defineQuery(`
|
|
*[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {
|
|
${postFields}
|
|
}
|
|
`);
|
|
|
|
export const postQuery = defineQuery(`
|
|
*[_type == "post" && slug.current == $slug] [0] {
|
|
content,
|
|
${postFields}
|
|
}
|
|
`);
|