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.
811
questions
1
vote
1
answer
2k
views
Passing CSS classes into sanity block-content root
Imagine following situation:
I retrieve rich text as block-content from sanity CMS. The block-content contains a single block, which could be for example <h2>Hello World</h2>. This HTML is ...
1
vote
2
answers
656
views
Debugging Sanity exec with VS Code
I'm using Sanity (sanity.io headless CMS) and doing some data migration with the CLI.
How do I (or, is it at all possible) to some how attach the vscode debugger and stop at breakpoints in migration ...
1
vote
1
answer
1k
views
Sanity.io - Add custom date to slug url
I'm building a Gatsby portfolio site with a Sanity back-end. The homepage of the site is going to feature a grid of tiles which link through to blog posts. I want the blog post URLS to have the ...
1
vote
1
answer
1k
views
Access file asset url
I have a schema with a file type, and I'm successfully pulling the right data with groq. My question is how do I access the absolute path for the file that's uploaded to sanity?
Example data:
{ ...
1
vote
2
answers
791
views
Angular4 Injecting Service class - code in constructor not finished when service method called?
I'm trying to get into Angular4/5. I have a connection to a CMS service called Sanity (https://www.sanity.io/). The issue I am having is that this service is injected to a ProductsComponent class and ...
1
vote
1
answer
3k
views
"query" is not a valid Page export field - When Trying to deploy NextJS13 and Sanity.io to Vercel
I'm learning NextJS13 and was following a blog tutorial online by Sonny Sangha 'Let’s build a BLOG with Next.js 13 (Sanity v3, TypeScript, Tailwind CSS, Auth, CMS, Preview Mode)'. Upon completion of ...
1
vote
2
answers
2k
views
Could not resolve dependency with sanity in nextjs app
I am trying to deploy my next.js project, but I keep getting the following error with everything I do:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! ...
1
vote
1
answer
3k
views
Sanity Array of Objects
I'm attempting to transform all my frontmatter from a legacy git based CMS into Sanity's ironically named CMS but I'm having difficulties with the arrays. For reference, here is my frontmatter:
...
1
vote
2
answers
1k
views
How to set the fill of SVGs that are imported from CDN?
I'm developing a website using Next JS and I want to display some SVG icons that I stored using Sanity. How do I display the SVG that I get from the Sanity CDN if I want to be able to dynamically ...
1
vote
2
answers
1k
views
Fetching documents
Using Sanity Studio I've created 2 documents in a simple schema "users" (the structure is not that important), and then updated each of them with some values, and published.
Trying to get ...
1
vote
1
answer
1k
views
Sanity.io GROQ: retrieve documents that have a key defined inside array of objects
I have documents that look like this
{
"_type": "celeb",
"name": "foo",
"facts: [
{a: 1, topics: {_ref: 'asd', _type: 'reference'}},
{a: 2},
...
1
vote
1
answer
661
views
How to compare arrays in GROQ
I have a blog with sanity CMS and I want to request related posts depending on corresponding tags from the current post which means I have to compare two arrays of tags.
My tags are described in post ...
1
vote
1
answer
890
views
Limit array of references to documents that have not been referenced yet
I have a "reference selector" (i.e. a module where editors can choose documents to reference) but I want to limit the results to the documents that have not been referenced yet.
This is the ...
1
vote
1
answer
1k
views
Sanity with React BlockContent displays only plain text
Ok, so I am working on a blog for my portfolio website, and I just got it working until I realized that when I style the body of my blog posts in Sanity Studio, those styles do not transfer to the ...
1
vote
3
answers
2k
views
Sanity io show blog posts by author
I'm learning Sanity io CMS and GROQ. I've build a simple blog using one the Sanity predefined blog schema. I've managed to show posts, a single post and the author page, showing name, image and bio.
...
1
vote
3
answers
2k
views
NextJs Google fonts issue - Only one font gets displayed
I'm connecting Google Fonts link to the HEAD section in _app.js file of my NextJs application. The link contains two fonts.
https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&family=...
1
vote
1
answer
837
views
Is it possible with Sanity? scheduled external API calls to Sanity
Here is what I would like to accomplish?
1- Make a fetch call to a news API everynight
2- Pull latest headlines
3- Import to Sanity...
Does Sanity let you do that? Does it have a cron job?
Thank you,
1
vote
1
answer
1k
views
How to auto reference to other post in Sanity.io?
i recently tried sanity.io CMS to manage content on my personal blog. however i'm facing a little difficulty to find part in the documentation about 'auto referencing' (this just my term). i want for ...
1
vote
1
answer
2k
views
Always resolve certain field references in groq query
We have certain type of fields that point to a reference that we want to resolve. Is there a way to search for these fields, however deep down the tree they are, and apply the "->" on it? We have ...
1
vote
1
answer
3k
views
How to create a unique number in Sanity.io?
I have a field of the type number defined on a document in my schema. When the user inputs a number, I want a validation which verifies that no another document of the same type has the same number ...
1
vote
1
answer
4k
views
Filter query result by field value inside array of objects [Sanity.io & GROQ]
I'm trying to find a product variant inside my list of products(on sanity.io using GROQ), to do so, I have the sku of the variant that I want.
The query I'm using is
*[_type == "product" && ...
1
vote
1
answer
535
views
Why Doesn't Prepare Render Properly in Sanity.IO
I am trying to customize the prview section for a document insanity.io. To that extent, I have created the following document:
export default {
name: 'news',
type: 'document',
title: 'News',
...
1
vote
1
answer
874
views
Sanity - How to set timezones correctly?
I set a date & time for an event with a datetime type, however its representation is skewed -2h.
I imagine that this is related to ha javascript l10n of datetime.
Could you help me to keep the ...
1
vote
1
answer
101
views
algolia-sanity updating doesn't work nextjs
i am trying to automatically update my algolia index by using the sanity-algolia package and the sanity webhook (i am using the legacy webhook) but it doesn't work.
Here's my /api/route.js file
import ...
1
vote
1
answer
360
views
Portabletext-svelte image from rich formatted text
I use Sanity.IO for my blog and sveltekit.
I use portabletext-svelte to change the json to html text and tailwindcss prose to make it pretty.
I know i have to build the URL so for that i have the &...
1
vote
1
answer
51
views
how to get a portion of useState stored data in another useState
In the project that I am working on currently I am fetching data from sanity and storing that data in a useState(), and that data is a collection of multiple restaurants, each restaurant has different ...
1
vote
1
answer
1k
views
Sanity GROQ query to not return nullish values
I was querying Sanity with GROQ and wanted to get response excluding nullish values in case there is no image url is available but if it is then return the image url.
Doing like this:
defined(image) =&...
1
vote
1
answer
3k
views
New nextjs 13 next/image component not loading with sanity.io image
I'm trying to get a simple next/image component displaying properly but the images just won't load. I'm using nextjs 13 which was just released so this is a new version of the component.
I'm using ...
1
vote
1
answer
963
views
Sanity HTTP API: How to add an array of references?
What is the correct way to add an array of references using the Sanity HTTP API?
I'm able to add a single reference:
const mutations = [{
createOrReplace: {
_id: '123',
_type: 'cms.article',
...
1
vote
1
answer
2k
views
How to use query param as a variable in groq sanity query inside getServerSideprops in next js?
I'm trying to implement search fuctionality in my blog project but facing problem in using variable in groq query(sanity) inside getServersideprops.
Here is my code
import React from 'react'
import { ...
1
vote
1
answer
17
views
Error: setAllcategories is not a function
Working currently with Nextjs and Sanity as Headless CMS for the backend part. As you can see down below I made a Categories.js file in components folder an trying to fetch some datas. I want to take ...
1
vote
1
answer
224
views
How to deploy React + Sanity app to Netlify
I currently worked on a Portfolio web application built using React and Sanity.io. After deploying to Netlify, all content in the Sanity was not showing.
Please, what am I not doing right?
I noticed I ...
1
vote
1
answer
340
views
How to get images from blockcontent body?
This is my code. Everything renders except images. How to get images in the right order from body? I'm using sanity-blocks-vue-component to render body block. While fetching query Im also fetching ...
1
vote
1
answer
978
views
Gallery schema not appearing on Sanity studio
So I have a Portfolio app, I want to add a Gallery section to it for displaying images. I created the schema(gallery.js) and added it on schema.js but it is not appearing on Sanity workspace. Any ...
1
vote
2
answers
1k
views
Next.js with Sanity not building Blog pages
I'm working on my first integration of Sanity with Next.Js, trying to add a blog to a personal site. Dev works fine, but when I go to deploy, or do a build, I get an error that it can't find one of ...
1
vote
1
answer
2k
views
Unable to add code blocks in Sanity CMS after I install the code-input plugin
I am learning to build a blog using Sanity CMS and React. I am new to Sanity.
I should be able to insert code snippets in my blog posts. So, I have installed the code-input plugin.
According to the ...
1
vote
1
answer
2k
views
Problem with rich text that I get from Sanity
import React from "react"
import {
Link,
graphql
} from "gatsby"
import Image from "gatsby-image"
import BlockContent from "@sanity/block-content-to-react"
import Layout from "../components/...
1
vote
1
answer
542
views
Sanity.io code input – how to add an input field for highlighted lines?
I've stuck trying to add highlightedLines field to Sanity.io code input. The only docs I've found yet are on npm page of the module, and there is an example data model:
{
_type: 'code',
language: '...
1
vote
1
answer
419
views
React update state of component after search through object
I have an object that is outputted from the reactIcons npm package https://www.npmjs.com/package/react-icons I am importing everything from one of the folders with import * as ReactIcons from 'react-...
1
vote
1
answer
2k
views
Can I reach a grandparent from a GROQ query?
I'm trying to run a GROQ query for my Sanity.io project that should filter out child documents that contain references based on a grandparents id. Is it possible to do so?
I've come to an ...
1
vote
1
answer
808
views
Fetch _id of last created document of given type in Sanity
In Sanity, for a given document type named message, how can I get the _id of the newest message document?
1
vote
1
answer
81
views
Sanity npm package throws type error on build
As the title says, I use next-sanity for my Next.js blog. I recently wanted to update all npm packages. Now I can´t run npm run build as the one of the dependncies itself throws a type error as ...
1
vote
2
answers
235
views
sanity groq not returning queried data
Im having trouble using groq to fetch data. All my other groq queries work expect this one. The data im trying to query works with the sainty groq vs plugin when i manually set the $slug variable but ...
1
vote
1
answer
50
views
NextJS / Sanity Fetch Logs
I keep getting verbose console output when using Sanity's fetch() function (from createClient in next-sanity) like so:
export async function getPeople(): Promise<Person[]> {
return ...
1
vote
1
answer
573
views
Next.js app router + Sanity revalidateTag() issues
I’m trying to get next app router + revalidateTag() to work with Sanity but it’s either completely unpredictable or I totally misunderstood something.
I now spent 5 full days trying to make it work ...
1
vote
2
answers
1k
views
Bust cache after content change with Sanity?
I'm using Sanity as a CMS and Next JS as my frontend. I’d like my site to be able to handle a reasonable amount of traffic so I think I need some caching.
However if an editor makes a change to the ...
1
vote
1
answer
374
views
Sanity.io studio image cropping and hotspot not working
I'm following a NEXT.JS 13 & Sanity tutorial and I'm not being able to crop and set the hotspot for my images in Sanity studio. I can open the cropping/hotspot tool and it shows everything OK, but ...
1
vote
1
answer
762
views
why does my API route in next.js is giving 404 error
why does my fetch request gives me the error "GET http://localhost:3000/api/db/getRideTypes 404 (Not Found)" when trying to fetch data from sanity client.
The partial code of Rideselector.js ...
1
vote
4
answers
388
views
how can I reach my Sanity Studio under a sub route of my NextJs application?
How can I use Studio by Sanity v3 as a subroute in NextJs V13 if I have the following folder structure?
├── My Application
│ ├── pages
│ └── app
│ ├── src
│ └── studio
│ ├── schema
│ ...
1
vote
1
answer
623
views
Setting up Sanity Studio with Next.js 13 front-end gives me a SyntaxError
I'm trying to set up Sanity Studio with my Next.js 13 front-end. I added http://localhost:3000 to my Sanity project CORS origin and then, I created this sanity.config.ts file:
import { defineConfig } ...