How to Fetch a Value in the Structurebuilder from a Page

1 replies
Last updated: Nov 1, 2021
I need to fetch a value in my Structurebuilder from a page. In this case, it’s which language the page has instead of having “en” as fixed, it should get the “language” value from that page. How would I go about doing it in this case? Is it possible to ad a GROQ query or something in
? The only value I can get from the `S.document()`seems to be the documentId, maybe somehow fetch the value dynamically using that ID?
export const getDefaultDocumentNode = (props) => {
  if (props.schemaType === "page") {
    return S.document().views([
        .options({ previewURL, selectedLanguage: "en" })
Oct 26, 2021, 11:17 AM
You can access information in the document inside of your
by using
. You could try passing that value to your 'selectedLanguage' option.
Nov 1, 2021, 8:25 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?