Here is my schema setup:
How do I query Groq to return the navItems and the navItemUrls within one query to use in a map function?
The only thing I can return is the top-level properties of personalnav when performing the GROQ query. I need to be able to use all of these properties to populate the dynamic data to each navigation button and map over them dynamic to leverage a server component in nextjs.
const personalnav = {
name: "personalnav",
type: "document",
title: "Personal Navigation",
fields: [
{
name: "title",
type: "string",
title: "Title"
},
{
name: "id",
type: "string",
title: "Id"
},
{
name: "navItems",
type: "array",
title: "Navigation items",
of: [{ type: "navItem" }]
}
]
};
const navItem = {
name: "navItem",
type: "object",
title: "NavItem",
fields: [
{
name: "text",
type: "string",
title: "Name of Link"
},
{
name: "description",
type: "string",
title: "Link Description that follows the Name of Link"
},
{
name: "navItemUrl",
type: "link", // references link object
title: "Nav Item URL"
}
]
};
export default navItem;
const link = {
name: "link",
type: "object",
title: "Link",
fields: [
{
name: "externalContent",
title: "Content is from an external source",
type: "boolean"
},
{
name: "linkUrl",
title: "Link URL",
description:
"Use this field to add a link to the source. For external links use full url e.g. ‘https://google.com/’. For internal links use the page path e.g. ‘companies’",
type: "string"
}
]
};
export default link;
const navItem = {
name: "navItem",
type: "object",
title: "NavItem",
fields: [
{
name: "text",
type: "string",
title: "Name of Link"
},
{
name: "description",
type: "string",
title: "Link Description that follows the Name of Link"
},
{
name: "navItemUrl",
type: "link", // references link object
title: "Nav Item URL"
}
]
};
export default navItem;
New contributor
Barrett Howell is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.