I have a simple singleton document schema defined in my Sanity/NextJS project, to model my "Colophon" page (richText
is a custom block field type):
export default {
title: 'Colophon',
name: 'colophon',
type: 'document',
__experimental_actions: ['update', 'publish'],
fields: [
{
title: 'Body',
name: 'body',
type: 'richText',
validation: Rule => Rule.required(),
},
],
};
I retrieve this document with a simple query in my NextJS application:
export async function getStaticProps() {
const colophon = await client.fetch(`
*[_type == "colophon"][0]
`);
// ...
};
Is it possible to write a GROQ query to retrieve the meta title defined in the schema, i.e. Colophon
? Although this is a singleton document, I would like to avoid repeating this string in my project if possible. At the moment, I can only see the fields on the document in my results, i.e. body
.
Thanks for reading!
question from:
https://stackoverflow.com/questions/65901665/is-it-possible-to-query-document-schema-metadata-in-sanity-groq 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…