Questions tagged [sanity]

Sanity is a structured content platform and API that also offers an open source, React-based Studio that functions as like a headless CMS on top of the Sanity APIs.

Filter by
Sorted by
Tagged with
3 votes
1 answer
723 views

It it possible to truncate text in a groq query?

I'd like to create an excerpt from a (portable) text field. Is this something that is possible? I know I can get the text value back using pt::text(body) and I can get values such as length from that. ...
Designer023's user avatar
  • 1,972
3 votes
1 answer
2k views

Can you create a folder of documents in Sanity and how?

I have a lot of documents of same type and i want to organize them in folders and subfolders. Is that possible in sanity?
Klimentina Djeparoska's user avatar
3 votes
1 answer
1k views

Next JS Rewrites for Sanity CMS giving 404 page after login

I'm currently hosting a Next JS site on Netlify with a Sanity CMS backend for content editing. I've got it configured to run on the single domain IE - examplesite.com has the front-end website, where ...
Isaac King's user avatar
3 votes
1 answer
1k views

Using variable/placeholder in the template literal GROQ queries - @nuxtjs/sanity

I need a reusable Nuxt component that fetches some data from Sanity.io. I'm using the @nuxtjs/sanity package, so the query looks like this: import { groq } from '@nuxtjs/sanity' const query = groq`*[...
Bruja's user avatar
  • 366
3 votes
3 answers
932 views

Data is not updated after changes in the Sanity Studio

I am quite new to Sanity v3 + Next.js v13. Everything works great on my test site, but I have a problem when I update a document (project) or add a new one in the Sanity Studio – these changes are not ...
podeig's user avatar
  • 2,671
3 votes
1 answer
590 views

How to custom preview mode in Sanity Studio with Nextjs

I have problem to show the preview mode because the url must contain few parameter that is "category" and "slug". (example in my picture bellow). This is the error url with ...
Toss's user avatar
  • 63
3 votes
2 answers
162 views

Error while mapping the sanity schema in my react webiste

I am trying to map a sanity schema, but I am unable to do so, please help me if any knows: This is the sanity schema categories.js which I want to traverse, here I want to traverse the features array ...
Yashwant's user avatar
3 votes
1 answer
640 views

Error: Duplicated files or mocks. ReactNative-Expo-sanity.io

so have been developing a react native app using Expo and sanity.io as back-end, when I implemented sanity as backend i started getting an error just on the mobile versions(ios simulator, and andorid ...
sebastian velez's user avatar
3 votes
1 answer
284 views

Gatsby development server stops working when repo is created on github. Sanity, Gatsby Error

I received a github repo backup from somebody elses account. The project is running gatsby, sanity cms and is hosted via netlify. When I extract the archive and saving the folder locally, I am ...
user5123123's user avatar
3 votes
1 answer
299 views

Escape HTML entities and render URL dynamically

The problem can be seen here I built a site using Sanity headless CMS and GatsbyJS on the frontend. I'm querying URLs dynamically so that it can be rendered inside the src attribute of an </iframe&...
Null isTrue's user avatar
  • 1,892
3 votes
1 answer
2k views

GraphQL - Gatsby.js- React component. - How to query with variables/arguments?

I have a React Component that needs to query data. And I want to pass arguments/variables to the query. But I don't know how to do that. For example. I have this blog item carousel that wants to query ...
Tim's user avatar
  • 881
3 votes
1 answer
1k views

Sanity Studio: conditionally hide fields based on value from a reference field

Is there a way to conditionally hide fields based on the value of a referenced field? I have two types: Destination and DestinationType Below is the reference from the Destination type to the ...
Ken Prince's user avatar
  • 1,486
3 votes
0 answers
76 views

Server Error: Unknown block type "code", please specify a serializer for it in the `serializers.types` prop

I am building a blog website using Sanity and NextJS. and facing error like: Server Error Error: Unknown block type "code", please specify a serializer for it in the serializers.types prop I'...
mrohitsingh's user avatar
3 votes
0 answers
596 views

How to get sanity client on v3 scripts?

I didn't find a way to get client on Sanity v3 script. The old version was getting it from 'part:@sanity/base/client' and it doesn't work for v3. Well, it's simple: import { getCliClient } from '...
Wellerson Miranda's user avatar
3 votes
3 answers
901 views

Problem Deploying a Next JS + Sanity Project to Vercel

I was on a project and used nextjs with sanity but after almost finishing my project, I just don't see any way to deploy it. Learning sanity took quite a bit of time but what meaning is there if I can'...
TheFlashExs's user avatar
3 votes
2 answers
1k views

Upstream dependency conflict, npm sanity/client

I'm trying to make a nextjs/sanity project at the moment, and I think I may have installed sanity client twice, but not entirely sure. This is the error I'm getting in the command terminal: npm ERR! ...
paparonnie's user avatar
3 votes
1 answer
215 views

Error while connecting sanity content lake to frontend

I'm getting an error while fetching blogs from sanity to my template, I'm creating a next.js website Error: Error: Unknown block type "undefined", please specify a serializer for it in the ...
Sushant Bansode's user avatar
3 votes
0 answers
1k views

TypeError: url.parse is not a function (fetching data from sanity.io)

I have been stuck on this thing for a week now. I am trying to fetch data from Sanity (http://sanity.io/) within a Vue (Vite) project, doing it exactly as this guide is showing: https://www.sanity.io/...
Blastius's user avatar
2 votes
4 answers
3k views

Parsing Error: Cannot find module '@babel/preset-env' for Sanity

For a React project, I installed Sanity under the schema folder and then I started adding different JS files into it, but even though there is no code in them, I get the error in the header for each ...
Batuhan Taştekin's user avatar
2 votes
3 answers
5k views

Vercel Build deply error: npm ERR! ERESOLVE unable to resolve dependency tree - While resolving: [email protected]

[20:19:35.061] Cloning github.com/oneboyfromife/macho-store (Branch: main, Commit: 48072bd) [20:19:35.209] Previous build cache not available [20:19:36.082] Cloning completed: 1.020s [20:19:36.317] ...
Owojori Akintunde's user avatar
2 votes
3 answers
3k views

My Gatsby GraphQL schema wont update with new Sanity schema

I am trying to update my CMS to enable a user-defined product slider. Upon adding the relevant schema to my sanity source files (This works) and adding the documents to the schema there is no update ...
Aiden Barrett's user avatar
2 votes
2 answers
2k views

Content is not updating until re-deploy nextjs 13 and sanity

Hello i am using nextjs 13 server components using /app directory and sanity studio. my code looks like this const Page = async () => { const query = groq`*[_type == "university"]`; ...
JoyShaheb's user avatar
  • 357
2 votes
1 answer
978 views

Reasoning with _raw and normal data in Gatsby, GraphQL and Sanity

I've just started using Gatsby with the Sanity headless CMS. For the most part it's pretty straight forward; but knowing best practises for querying the data through GraphQL is still bothering me. ...
shennan's user avatar
  • 11.2k
2 votes
2 answers
6k views

Server Error Error: Configuration must contain projectId‘

I followed this tutorial: https://youtu.be/mx1dbMzd3tU When i try to connect sanity and next i get this error Server Error Error: Configuration must contain projectId‘
Avidu's user avatar
  • 37
2 votes
2 answers
4k views

SVG is being passed to img src as an object

For a website using NextJS and Sanity.io, I am importing an image locally import large_logo from '../../assets/logo-large-1200x630.svg and am calling it inside an img tag as src <img src={...
ebsco's user avatar
  • 31
2 votes
4 answers
1k views

Sanity Error: `dataset` must be provided to perform queries with React

I'm trying to create a blog with Sanity CMS; when I try to get data from Sanity database i get that "Error: dataset must be provided to perform queries" I got client.js component with ...
Sebastian Lewy's user avatar
2 votes
2 answers
563 views

How to define NOT is sanity.io structure builder?

I'm trying to filter all products without categories (which is array of references) and can't find how to do it. S.listItem() .title('Without category') .id('productsWithoutCategories') ....
Daria Moreno-Gogoleva's user avatar
2 votes
1 answer
4k views

Customizing schema fields in sanity.io

In sanity studio schema I made some object type with one field, dependent of other. If "all" field check to true, then "date" field should be hidden or disabled. But I don't know ...
Daria Moreno-Gogoleva's user avatar
2 votes
2 answers
1k views

Sanity GROQ: How do i get drafts for the array of references in a document?

I have a document type page which contains an array of blocks that are the references to other object types. When i fetch the data for page document, it returns draft data for document but not for the ...
Mutahhar Ahmad's user avatar
2 votes
4 answers
3k views

How to filter Sanity posts by category title?

Here what I've done in vision *[_type == "post" && categories == SOCIAL ]{ _id, title } It returned No documents found in dataset production that match query: *[_type == "...
Shaiful Rizal Shaharudin's user avatar
2 votes
1 answer
1k views

How to create custom resolvers for Gatsby page queries?

I have a Gatsby application pulling data from Sanity. This is Sanity's schema for the course.js: import video from './video' export default { // Computer name name: `courses`, // Visible ...
André Casal's user avatar
  • 1,110
2 votes
1 answer
983 views

Live Preview mode Sanity on NextJS 13

I cant seem to check if preview mode is activated or not for my website. I was following a YouTube tutorial but I think it might be outdated when I am using the new NextJS update. This is what i was ...
Branzed's user avatar
  • 51
2 votes
1 answer
1k views

Sanity Query Does Not Return Updated Data Consistently

I have a "film" category in my Sanity database which has an array of comments. In my UI, I present a pic of the film with the comments listed below the film. I created a function to add ...
Scott F.'s user avatar
2 votes
1 answer
2k views

Sanity query in an array of references

I have an array of articles with array of tags with references: _type: "article", tags: [ { _id: "123", _rev: "123", _type: "articleTag", key: { ...
kizoso's user avatar
  • 1,216
2 votes
1 answer
2k views

Sanity.io, is any way to to change field type painlessly?

I have quite a lot documents in the sanity.io with completed fields. There is a need to change field type. And here are the problem: Now I need to rewrite this field from old to the new and delete ...
kizoso's user avatar
  • 1,216
2 votes
1 answer
641 views

previewData is not a function error after updating NextJS

I have a NextJS and Sanity.io blog project. Today I updated NextJS from 13.2.3 to 13.4.2 and when I try to run it, I get this error: Error: (0 , next_headers__WEBPACK_IMPORTED_MODULE_1__.previewData) ...
Vilmos Szabó's user avatar
2 votes
2 answers
344 views

Error: No "sanity.json" file found in plugin "@sanity/vision"

As I was creating my new sanity project on my terminal while running "sanity init" during the process I received an error of: "Error: No "sanity.json" file found in plugin &...
MegaMindTheCoder's user avatar
2 votes
2 answers
290 views

How to remove a specific document from sanity desk structure?

I added the media library plugin to my sanity structure builder but want to remove the 'media tag' document that gets created by the plugin However, you can override this behaviour by defining your ...
Burger Sasha's user avatar
2 votes
1 answer
745 views

Module '"sanity"' has no exported member 'defineConfig'

I've just finished working on a project using Next.js 13 and Sanity as a headless CMS. Here is the issue I'm experiencing: When I run vercel build I get the error that 'sanity' has no exported member ...
Olowoseun's user avatar
2 votes
3 answers
4k views

Module not found: Can't resolve '@sanity/client'

I keep getting this error on localhost Failed to compile ./lib/client.js:1:0 Module not found: Can't resolve '@sanity/client' > 1 | import sanityClient from '@sanity/client'; 2 | import ...
DiwSlow's user avatar
  • 21
2 votes
1 answer
989 views

Preview content on site in Sanity not working

I'm following the Sanity docs on how to add a content preview. After updating the sanity.json and adding a resolveProductionUrl.js file according to docs I should be able to see a menu item in context ...
Tomasz Mularczyk's user avatar
2 votes
1 answer
1k views

Text highlight is not being applied at front-end in Sanity CMS

I am trying to create a blog using Sanity Headless CMS and React for the frontend. I have made a decorator for highlighting text. As you can see in the image below, in the editor, the highlighted text ...
HKS's user avatar
  • 774
2 votes
1 answer
878 views

Convert String type to slug type for sanity io

I am importing data from an external API into my sanity schema and the API contains the slug in the form of a string. I have tried removing the double quotes of the string and making it single quoted ...
Marium Ali's user avatar
2 votes
1 answer
1k views

How to use internal links in sanity.io and gatsby with gatsby-source-sanity?

I have created an internalLink type following the sanity documentation and as per the gotcha note about using internalLinks with a graphql api, I have created it as a separate type as follows: export ...
aks94's user avatar
  • 375
2 votes
1 answer
635 views

Is it safe to edit the schema of a blog post in Sanity, after I already have added 4-5 long posts (using the same schema)?

I currently have a blog running on Next.js + Sanity. I have had a lot of success, but in the past when setting it all up encountered a scary error while editing the blog post schema, that basically ...
Zach White's user avatar
2 votes
1 answer
1k views

Order by random in Sanity.io GROQ query not working?

Sanity.io is awesome! But as I'm just beginning, I cannot find some things yet I know in e.g. MySQL. According to the GROQ cheat sheet I should be able to randomly sort and slice (LIMIT + OFFSET in ...
Jos's user avatar
  • 1,474
2 votes
1 answer
314 views

Is it possible to set default geopoint in the sanity.io?

I have a field: { name: 'location', title: 'Map', type: 'geopoint' } and I use @sanity/google-maps-input. It is great, but default localization is New York. How can I change it to another ...
kizoso's user avatar
  • 1,216
2 votes
1 answer
193 views

How to use arithmetic operator to calculate sum

I have a review type with a rating field that contains a number from 1 to 5. Now I'd like to calculate the average rating. Relevant schema: { name: 'rating', title: 'Rating', ...
jgillich's user avatar
  • 73.8k
2 votes
2 answers
2k views

How do I fix a 'Missing enviornment variable' in Sanity?

I have tried everything to fix it but still getting the error Uncaught error: Missing environment variable: NEXT_PUBLIC_SANITY_DATASET http://localhost:3333/static/sanity-5377bc10.js:4605:43956 Error:...
I byte's user avatar
  • 21
2 votes
5 answers
2k views

Sanity Deployment on Vercel Issue: Cannot find module 'sanity' even though package is installed

So i'm trying to deploy sanity/nextjs on vercel. It runs fine locally but for the production build I keep getting the same error. Here's the main error: > build > next build info - Linting and ...
Bob's user avatar
  • 21

1
2
3 4 5
17