mirror of
https://github.com/vercel/commerce.git
synced 2025-08-06 08:51:25 +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
55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import {defineField} from 'sanity'
|
|
import {BlockElementIcon} from '@sanity/icons'
|
|
|
|
export default defineField({
|
|
name: 'reusableSection',
|
|
type: 'object',
|
|
title: 'Reusable section',
|
|
icon: BlockElementIcon,
|
|
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',
|
|
},
|
|
{
|
|
name: 'section',
|
|
type: 'object',
|
|
title: 'Section',
|
|
description: 'Reference to an existing section (only 1 allowed).',
|
|
fields: [
|
|
{
|
|
title: 'Existing section',
|
|
name: 'existingSection',
|
|
type: 'reference',
|
|
to: [{type: 'section'}],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
|
|
preview: {
|
|
select: {
|
|
title: 'title',
|
|
disabled: 'disabled',
|
|
},
|
|
prepare(selection) {
|
|
const {title, disabled} = selection
|
|
|
|
return {
|
|
title: `${title}`,
|
|
subtitle: `Reusable section ${disabled ? '(⚠️ Disabled)' : ''}`,
|
|
media: BlockElementIcon,
|
|
}
|
|
},
|
|
},
|
|
})
|