sanity-plugin-authoring

tarafından sanity-io

Sanity Studio eklentilerini, genel eklenti ve araç API'lerini kullanarak açıklayın ve oluşturun. Kullanıcıya yönelik eklentiler oluştururken, eklentiler aracılığıyla araçlar eklerken veya bir…

npx skills add https://github.com/sanity-io/sanity --skill sanity-plugin-authoring

Sanity Plugin Authoring

What A Plugin Is

A Sanity Studio plugin is a named configuration bundle that can be added to a Studio through the plugins array. Plugin configuration accepts most workspace config properties, except workspace-owned settings such as dataset, projectId, auth, and theme.

Always give plugins a stable unique name. Prefer definePlugin() so editors expose useful types and autocomplete.

import {definePlugin} from 'sanity'

export const previewUrlPlugin = definePlugin({
  name: 'preview-url-plugin',
  document: {
    productionUrl: async (prev, {document}) => {
      const slug = document.slug?.current
      return slug ? `https://example.com/${slug}` : prev
    },
  },
})

Configurable Plugins

Use definePlugin((options) => ({...})) when callers need to configure behavior.

export const myPlugin = definePlugin<{enabled?: boolean}>((options) => ({
  name: 'my-plugin',
  tools: options.enabled === false ? [] : [myTool],
}))

Keep option namespaces extensible. Prefer object shapes such as {feature: {enabled: true}} instead of direct booleans when future settings are likely.

What Plugins Can Provide

Common plugin properties:

  • document: Document actions, badges, production URL resolvers, and new document defaults.
  • form: Form customizations, asset sources, and custom input rendering.
  • plugins: Nested plugins.
  • tools: Studio tools contributed by the plugin.
  • schema: Schema types and initial value templates.
  • studio: Studio component overrides and middleware.
  • i18n: Locale resource bundles used by plugin UI.
  • title: Human-readable plugin name.
  • onUncaughtError: Custom error handling, logging, or telemetry.

Use the smallest surface that solves the feature.

Tools In Plugins

A tool is a top-level Studio view with routing and predictable URLs. Tools commonly represent full-screen workflows such as Structure, Vision, Dashboard, or Presentation.

When adding a tool through a plugin:

  • Add it through the plugin tools property.
  • Give it a stable name, title, component, and router when needed.
  • Remember tool visual order is affected by the order tools are added, followed by tools added through plugins.
  • Use studio.components.toolMenu when the visual menu order needs custom rendering.
  • Use the top-level tools reducer pattern when changing the default opened tool, because visual menu order alone does not choose the default route.

Studio Components

studio.components can customize parts of the Studio UI. Components that receive renderDefault are middleware: call props.renderDefault(props) unless intentionally replacing the default UI.

Use this for UI wrappers, navigation changes, or tool menu ordering. Be careful not to change scroll containers or layout ownership accidentally.

Locale Resources

If a plugin renders UI text, add an i18n bundle instead of hard-coding user-facing strings. The usual file shape is:

feature/
├── i18n/
│   ├── index.ts
│   └── resources.ts
└── plugin/
    └── index.ts

In i18n/index.ts, define a namespace and default US English bundle:

import {type LocaleResourceBundle} from '../../i18n'

export const featureNamespace: 'feature' = 'feature'

export const featureUsEnglishLocaleBundle: LocaleResourceBundle = {
  locale: 'en-US',
  namespace: featureNamespace,
  resources: () => import('./resources'),
}

export type {FeatureLocaleResourceKeys} from './resources'

In i18n/resources.ts, export the default strings and key type:

const featureLocaleStrings = {
  'action.example': 'Example',
}

export type FeatureLocaleResourceKeys = keyof typeof featureLocaleStrings

export default featureLocaleStrings

Then register the bundle from the plugin:

import {featureUsEnglishLocaleBundle} from '../i18n'

export const feature = definePlugin({
  name: 'sanity/feature',
  i18n: {
    bundles: [featureUsEnglishLocaleBundle],
  },
})

Before Coding

  1. Identify whether the feature is a plugin, a tool, a schema extension, a form extension, or a document extension.
  2. Check existing plugin examples in the repo.
  3. Choose a stable plugin name.
  4. Decide whether the plugin needs options.
  5. Add focused tests for the configured behavior.

For Sanity monorepo default plugin wiring, read sanity-core-plugin after this skill.

References

sanity-io tarafından daha fazla skill

tdd
sanity-io
Kırmızı-yeşil-yeniden düzenleme döngüsüyle test odaklı geliştirme. Kullanıcı TDD kullanarak özellikler geliştirmek veya hataları düzeltmek istediğinde, "kırmızı-yeşil-yeniden düzenleme"den bahsettiğinde, istediğinde…
performance-optimization
sanity-io
Uygulama performansını optimize eder. Performans gereksinimleri olduğunda, performans düşüşlerinden şüphelendiğinizde veya Core Web Vitals ya da yükleme süreleri…
content-experimentation-best-practices
sanity-io
Dönüşüm ve etkileşimi artırmak için içerik deneyleri tasarlama, yürütme ve analiz etme konusunda yapılandırılmış rehberlik. Hipotez çerçeveleri, metrik seçimi, örneklem büyüklüğü hesaplama ve A/B ile çok değişkenli deneylerde istatistiksel anlamlılık testini kapsar. Sonuçları yorumlamak için p-değerleri, güven aralıkları, güç analizi ve Bayes yöntemleri hakkında ayrıntılı kaynaklar sunar. Varyantları alan düzeyinde yönetmek ve harici bağlantı kurmak için CMS entegrasyon modelleri sağlar...
content-modeling-best-practices
sanity-io
Yapılandırılmış içerik modelleme rehberliği: şema tasarımı, yeniden kullanılabilirlik ve çok kanallı dağıtım için. Temel prensipleri kapsar: içeriği sayfa yerine veri olarak ele almak, tek doğruluk kaynağını korumak, gelecekteki kanallar için tasarlamak ve editör iş akışlarını optimize etmek. Referanslar ile gömülü nesneler arasında karar çerçeveleri, endişelerin ayrıştırılması ve içerik yeniden kullanım desenleri sunar. Düz, hiyerarşik ve yönlü yaklaşımlar için taksonomi ve sınıflandırma rehberliği sağlar. Şunlar için geçerlidir...
portable-text-conversion
sanity-io
HTML ve Markdown içeriğini Sanity için Portable Text bloklarına dönüştürün. Eski CMS'lerden içerik taşırken, HTML veya Markdown'ı Sanity'ye aktarırken kullanın.
portable-text-serialization
sanity-io
Portable Text'i React, Svelte, Vue, Astro, HTML, Markdown ve düz metne dönüştürüp serileştirin. Herhangi bir ön uçta Portable Text işleme uygularken kullanın…
sanity-best-practices
sanity-io
Sanity CMS geliştirme için çerçeveler ve konular arasında kapsamlı en iyi uygulamalar ve entegrasyon kılavuzları. Next.js, Nuxt, Astro, Remix, SvelteKit ve Angular dahil olmak üzere 10'dan fazla çerçeve entegrasyonunu, çerçeveye özel desenler ve kurulum rehberliği ile kapsar. Şema tasarımı, GROQ sorgu optimizasyonu, Görsel Düzenleme, Portable Text, görseller, TypeGen, yerelleştirme ve içerik taşımaları için konu kılavuzları içerir. Görev türüne göre yalnızca ilgili kılavuzları yüklemek için hızlı başvuru yapısı sağlar,...
sanity-migration
sanity-io
Diğer CMS ve içerik sistemlerinden Sanity’ye geçişleri planlar, uygular ve gözden geçirir. AEM, Adobe Experience Manager, Contentful, Strapi, Webflow, WordPress, Payload, Drupal, Markdown/MDX/frontmatter dosyaları, WXR/XML dışa aktarımları, CMS API’leri, veritabanı dökümleri, statik HTML’den Sanity’ye geçiş veya platform değişikliği yaparken ya da çıkarma, dönüştürme, Portable Text çevirisi, varlık geçişi, yönlendirmeler, doğrulama ve kesinti iş akışları tasarlarken kullanın.
data-analysisdatabasedevelopment