You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each of these items can be null, according to typegen, which causes a lot of if-checks in my vue code. Is there a way to tell TypeGen that these are singletons/always defined?
This is an example of my singleton code for SEO
import {defineField, defineType} from 'sanity'
import {TextAreaInput} from '@/components/TextAreaInput'
import {SparkleIcon as Icon} from '@sanity/icons'
export default defineType({
name: 'seo',
title: 'SEO',
type: 'document',
icon: Icon,
fields: [
defineField({
type: 'string',
name: 'meta_title',
title: 'Meta Title',
validation: (rule) => rule.required(),
description: 'Website titel voor de tab title, metadata en zoekmachines',
}),
defineField({
type: 'text',
name: 'meta_description',
title: 'Meta Description',
validation: (rule) => rule.required(),
description:
'Korte paragraaf voor zoekmachines, metadata en social sharing. Dit is een beknopte samenvatting die zoekmachines en gebruikers helpt te begrijpen waar de pagina over gaat, ideale lengte van tussen 70 en 160 karakters',
components: {
input: (props) => <TextAreaInput {...props} min={70} max={160} />,
},
}),
defineField({
type: 'image',
name: 'meta_image',
title: 'OG Image',
description:
'De afbeelding die wordt weergegeven wanneer de pagina op sociale media wordt gedeeld, wat de zichtbaarheid en aantrekkingskracht van de gedeelde link vergroot.',
}),
],
})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using the following query to fetch a few singletons
The types of settings, socials and seo are singletons in my Sanity Studio (so they will always be defined)
However when using TypeGen the result is
Each of these items can be null, according to typegen, which causes a lot of if-checks in my vue code. Is there a way to tell TypeGen that these are singletons/always defined?
This is an example of my singleton code for SEO
Beta Was this translation helpful? Give feedback.
All reactions