mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
.github
.vscode
app
components
helpers
lib
sanity
components
desk
schemas
blocks
documents
objects
banner.ts
blurbSection.tsx
filteredProductList.ts
hero.ts
linkExternal.ts
linkInternal.ts
mainImage.ts
menu.ts
reusableSection.tsx
seo.tsx
slider.ts
uspSection.ts
singletons
index.ts
slugWithLocalizedType.ts
utils
constants.ts
languages.ts
localizedTypes.ts
queries.tsx
sanity.api.ts
sanity.client.ts
sanity.fetch.ts
sanity.image.ts
sanity.types.ts
shopify
storm
constants.ts
constants.tsx
type-guards.ts
utils.ts
messages
plugins
public
.env.example
.eslintrc.js
.gitignore
.npmrc
.nvmrc
.prettierignore
README.md
components.json
i18n-config.ts
license.md
middleware.ts
next.config.js
package.json
playwright.config.ts
pnpm-lock.yaml
postcss.config.js
prettier.config.js
sanity.config.ts
tailwind.config.js
tsconfig.json
64 lines
1.3 KiB
TypeScript
64 lines
1.3 KiB
TypeScript
import {defineField} from 'sanity'
|
|
import {StarIcon} from '@sanity/icons'
|
|
|
|
export default defineField({
|
|
name: 'uspSection',
|
|
type: 'object',
|
|
title: 'USP section',
|
|
icon: StarIcon,
|
|
fieldsets: [
|
|
{
|
|
name: 'layoutSettings',
|
|
title: 'Layout settings'
|
|
},
|
|
],
|
|
fields: [
|
|
{
|
|
name: 'disabled',
|
|
type: 'boolean',
|
|
title: 'Disabled?',
|
|
description: 'Set to true to disable this section.',
|
|
initialValue: 'false',
|
|
validation: (Rule) => Rule.required(),
|
|
},
|
|
{
|
|
name: 'title',
|
|
type: 'string',
|
|
title: 'Title',
|
|
description: 'Title will only be used internally.',
|
|
validation: (Rule) => Rule.required(),
|
|
},
|
|
{
|
|
name: 'usps',
|
|
type: 'array',
|
|
title: 'USPs',
|
|
description: 'Create USPs or refer to existing USP.',
|
|
of: [
|
|
{
|
|
type: 'reference',
|
|
to: [{
|
|
type: 'usp',
|
|
}],
|
|
},
|
|
],
|
|
validation: (Rule) => Rule.required().min(2).max(4),
|
|
},
|
|
],
|
|
|
|
preview: {
|
|
select: {
|
|
title: 'title',
|
|
disabled: 'disabled'
|
|
},
|
|
prepare(selection) {
|
|
const {title, disabled} = selection
|
|
|
|
return {
|
|
title: `${title}`,
|
|
subtitle: `USP section ${disabled ? '(⚠️ Disabled)' : ''}`,
|
|
media: StarIcon,
|
|
}
|
|
},
|
|
},
|
|
})
|