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.

Sanity treats content as structured data and makes it easily available over an API. The collaborative editor, called the Content Studio, is a fully customizable, client-side web application. Documentation here.

833 questions
3
votes
1 answer

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 The problem is when the user adds an URL containing…
Null isTrue
  • 1,882
  • 6
  • 26
  • 46
3
votes
1 answer

How to download file from Sanity via HTTP?

I would like to know if there is possibility to download file from Sanity with HTTP request? I only have reference ID: { file: { asset: { _ref: "file-fxxxxxxxxxxxxxxxxxxxx-xlsx" _type: "reference" } } } I would…
ROKIKOKI
  • 571
  • 2
  • 9
  • 24
3
votes
1 answer

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`*[_type == "article"][0].title` export default { …
Bruja
  • 368
  • 2
  • 10
3
votes
1 answer

How to filter references based on change in another reference?

I have created an object with 3 reference fields - categories, subcategories, and types. I want the subcategories to show subcategories related to the selected category. { title: "Product Category", name: "category", type:…
user10261767
3
votes
1 answer

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 an x amount of items and an x amount of offset…
Tim
  • 861
  • 1
  • 12
  • 27
3
votes
1 answer

How can I validate the dimensions of an uploaded image in Sanity?

I have an image type field in Sanity (docs) and I need to make sure that the dimensions are within a particular range to avoid breaking the website they're going on. Sanity offers validations, but the image type only has “required” and “custom”…
coreyward
  • 77,547
  • 20
  • 137
  • 166
3
votes
1 answer

sanity.io - Adding color the text editor for the "block" type

I have an object of type block to get a WYSIWYG editor. It looks like this: { title: "Block", type: "block", styles: [ { title: "Normal", value: "normal" }, { title: "H1", value: "h1" }, { title: "H2", value: "h2" }, { title:…
Enrique Moreno Tent
  • 24,127
  • 34
  • 104
  • 189
3
votes
1 answer

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?
3
votes
1 answer

Preview a reference

I want to preview a reference name in the studio I have and icon type, for example one which has the title 'facebook' export default { name: 'icon', title: 'Icon', type: 'document', fields: [ { name: 'name', title: 'Name', …
Ben Gannaway
  • 1,053
  • 1
  • 14
  • 28
3
votes
1 answer

How to import CSV to sanity.io

Im a hobby programmer exploring the free version of the new headless CMS sanity (www.sanity.io). Bumping into a problem when trying to upload / import data into my project: Is there a way to import data from a csv file? Example from docs only…
3
votes
1 answer

How to define a tokenized tag field in Sanity?

I've seen people sport beautiful tokenized tag-fields in their Sanity studios. I don't think they are using a plug-in, so what's the incantation that will turn my homely array of strings into a tokenized tag field?
thomax
  • 9,213
  • 3
  • 49
  • 68
2
votes
1 answer

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) is not a function Here's the code: import {…
Vilmos Szabó
  • 167
  • 1
  • 2
  • 10
2
votes
0 answers

How to implement nested list using @portabletext/react npm in nextjs with sanity.io

i get stuck when wanna implement nested list using @portabletext/react package in nextjs, i need to show my list (in this case using bullet list) in different condition. In the normal condition to be the first picture. and then in the other…
Toss
  • 63
  • 4
2
votes
0 answers

POST request to Sanity CMS using Next.js API & next-connect resulting in 500 ERROR

I am having trouble making a POST request of user info on a register form to the Sanity CMS.I am using Next.js & next-connect. I am getting a 500 error when making the request. Here is a snippet of code from the register.js front end page: const…
Calathea
  • 21
  • 2
2
votes
2 answers

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 "@sanity/vision"" I have been trying to solve this error for quite some time.…
MegaMindTheCoder
  • 125
  • 3
  • 12