{
	// Place your sanitypress workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {
	// 	"scope": "javascript,typescript",
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }

	// Sanity

	"module schema": {
		"prefix": ["schema-module", "module-schema"],
		"scope": "typescript,typescriptreact",
		"body": [
			"import { defineField, defineType } from 'sanity'",
			"import { getBlockText } from '@/sanity/lib/utils'\n",
			"export default defineType({",
			"\tname: '${TM_FILENAME_BASE}',",
			"\ttitle: '${TM_FILENAME_BASE/^([a-z])|-([a-z])|\\.([a-z]+)/${1:/upcase}${2:+ }${2:/downcase}${3:+ (}${3:/downcase}${3:+)}/g}',",
			"\ttype: 'object',",
			"\t// icon: Vsc,",
			"\tfields: [",
			"\t\tdefineField({",
			"\t\t\tname: 'intro',",
			"\t\t\ttype: 'array',",
			"\t\t\tof: [{ type: 'block' }],",
			"\t\t}),",
			"\t\t$1",
			"\t],",
			"\tpreview: {",
			"\t\tselect: {",
			"\t\t\tintro: 'intro',",
			"\t\t},",
			"\t\tprepare: ({ intro }) => ({",
			"\t\t\ttitle: getBlockText(intro),",
			"\t\t\tsubtitle: '${TM_FILENAME_BASE/^([a-z])|-([a-z])|\\.([a-z]+)/${1:/upcase}${2:+ }${2:/downcase}${3:+ (}${3:/downcase}${3:+)}/g}',",
			"\t\t}),",
			"\t},",
			"})",
		],
	},

	"schema field": {
		"prefix": ["field", "schema-field", "df"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: '${1:string}',",
			"\ttype: '${2:string}',",
			"}),$3",
		],
	},

	"module options field": {
		"prefix": ["field-module-options", "module-options-field"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: 'options',",
			"\ttype: 'module-options',",
			"\tgroup: 'options',",
			"}),",
		],
	},

	"PortableText field": {
		"prefix": ["field-portable-text", "portable-text-field", "pt", "content"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: '${1:content}',",
			"\ttype: 'array',",
			"\tof: [{ type: 'block' }],",
			"}),",
		],
	},

	"CTA field": {
		"prefix": ["field-cta", "cta-field"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: 'ctas',",
			"\ttitle: 'Call-to-actions',",
			"\ttype: 'array',",
			"\tof: [{ type: 'cta' }],",
			"}),",
		],
	},

	"image field": {
		"prefix": ["field-image", "image-field"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: 'image',",
			"\ttype: 'image',",
			"\toptions: {",
			"\t\thotspot: true,",
			"\t},",
			"\tfields: [",
			"\t\tdefineField({",
			"\t\t\tname: 'alt',",
			"\t\t\ttype: 'string',",
			"\t\t}),",
			"\t\tdefineField({",
			"\t\t\tname: 'loading',",
			"\t\t\ttype: 'string',",
			"\t\t\toptions: {",
			"\t\t\t\tlist: ['lazy', 'eager'],",
			"\t\t\t\tlayout: 'radio',",
			"\t\t\t},",
			"\t\t\tinitialValue: 'lazy',",
			"\t\t}),",
			"\t],",
			"}),",
		],
	},

	"items array field": {
		"prefix": ["field-items-array", "items-array-field"],
		"scope": "typescript,typescriptreact",
		"body": [
			"defineField({",
			"\tname: 'items',",
			"\ttype: 'array',",
			"\tof: [",
			"\t\tdefineArrayMember({",
			"\t\t\ttype: 'object',",
			"\t\t\tfields: [",
			"\t\t\t\tdefineField({",
			"\t\t\t\t\tname: '${0:content}',",
			"\t\t\t\t\ttype: 'array',",
			"\t\t\t\t\tof: [{ type: 'block' }],",
			"\t\t\t\t}),",
			"\t\t\t\t$1",
			"\t\t\t],",
			"\t\t\tpreview: {",
			"\t\t\t\tselect: {",
			"\t\t\t\t\tcontent: '${0:content}',",
			"\t\t\t\t},",
			"\t\t\t\tprepare: ({ ${0:content} }) => ({",
			"\t\t\t\t\ttitle: getBlockText(${0:content}),",
			"\t\t\t\t}),",
			"\t\t\t},",
			"\t\t}),",
			"\t],",
			"}),",
		],
	},

	"schema groups": {
		"prefix": ["schema-groups", "groups-schema"],
		"scope": "typescript,typescriptreact",
		"body": [
			"groups: [",
			"\t{ name: 'content', default: true },",
			"\t{ name: '${1:options}' },",
			"],",
		],
	},

	"schema fieldsets": {
		"prefix": ["schema-fieldsets", "fieldsets-schema"],
		"scope": "typescript,typescriptreact",
		"body": [
			"fieldsets: [",
			"\t{ name: '${1:options}', options: { columns: 2 } },",
			"],",
		],
	},

	"schema preview": {
		"prefix": ["schema-preview", "preview-schema"],
		"scope": "typescript,typescriptreact",
		"body": [
			"preview: {",
			"\tselect: {",
			"\t\t${0:content}: '${0:content}',$1",
			"\t},",
			"\tprepare: ({ ${0:content} }) => ({",
			"\t\ttitle: getBlockText(${0:content}),",
			"\t}),",
			"},",
		],
	},

	// Next.js

	"Module component": {
		"prefix": ["component-module", "module-component"],
		"scope": "typescriptreact",
		"body": [
			"import { PortableText } from 'next-sanity'\n",
			"export default function ${TM_FILENAME_BASE}({ intro }: Partial<{ intro: any }>) {",
			"\treturn (",
			"\t\t<section className=\"section\">",
			"\t\t\t{intro && (",
			"\t\t\t\t<header className=\"richtext\">",
			"\t\t\t\t\t<PortableText value={intro} />",
			"\t\t\t\t</header>",
			"\t\t\t)}\n",
			"\t\t\t$1",
			"\t\t</section>",
			"\t)",
			"}",
		],
	},
}

.vscode/sanitypress.code-snippets