sanity-best-practices
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSanity Best Practices
Sanity最佳实践
Comprehensive best practices guide for Sanity development, maintained by Sanity. Contains rules across 10 categories, prioritized by impact to guide schema design, query optimization, and frontend integration.
由Sanity维护的Sanity开发综合最佳实践指南。包含10个类别的规则,按影响优先级排序,用于指导Schema设计、查询优化和前端集成。
When to Apply
适用场景
Reference these guidelines when:
- Writing GROQ queries or optimizing performance
- Designing content schemas
- Implementing Visual Editing and live preview
- Working with images, Portable Text, or page builders
- Configuring Sanity Studio structure
- Setting up TypeGen for type safety
- Implementing localization
- Migrating content from other systems
在以下场景中参考本指南:
- 编写GROQ查询或优化性能
- 设计内容Schema
- 实现Visual Editing和实时预览
- 处理图片、Portable Text或页面构建器
- 配置Sanity Studio结构
- 设置TypeGen以实现类型安全
- 实现本地化
- 从其他系统迁移内容
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | GROQ Performance | CRITICAL | |
| 2 | Schema Design | HIGH | |
| 3 | Visual Editing | HIGH | |
| 4 | Images | HIGH | |
| 5 | Portable Text | HIGH | |
| 6 | Page Builder | MEDIUM | |
| 7 | Studio Configuration | MEDIUM | |
| 8 | TypeGen | MEDIUM | |
| 9 | Localization | MEDIUM | |
| 10 | Migration | LOW-MEDIUM | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | GROQ性能 | 关键 | |
| 2 | Schema设计 | 高 | |
| 3 | Visual Editing | 高 | |
| 4 | 图片 | 高 | |
| 5 | Portable Text | 高 | |
| 6 | 页面构建器 | 中 | |
| 7 | Studio配置 | 中 | |
| 8 | TypeGen | 中 | |
| 9 | 本地化 | 中 | |
| 10 | 迁移 | 低-中 | |
How to Use
使用方法
Read individual rule files for detailed explanations and code examples:
rules/groq-optimizable-filters.md
rules/schema-data-over-presentation.md
rules/_sections.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
- Framework-specific notes (when applicable)
阅读单个规则文件以获取详细说明和代码示例:
rules/groq-optimizable-filters.md
rules/schema-data-over-presentation.md
rules/_sections.md每个规则文件包含:
- 规则重要性的简要说明
- 错误代码示例及解释
- 正确代码示例及解释
- 额外背景信息和参考资料
- 特定框架说明(如适用)
Framework Integration
框架集成
Framework-specific guidance (Next.js, Astro, Remix, etc.) is available via the Sanity MCP server using and tool calls when available. If the MCP server is not configured, run to set it up.
list_sanity_rulesget_sanity_rulesnpx sanity@latest mcp configure特定框架指南(Next.js、Astro、Remix等)可通过Sanity MCP服务器使用和工具调用获取(如可用)。如果未配置MCP服务器,请运行进行设置。
list_sanity_rulesget_sanity_rulesnpx sanity@latest mcp configure