Skip to content

Commit dfcdd28

Browse files
claude[bot]clauderuneb
authored
docs: fix schema.md icon examples for @sanity/icons v5 subpath imports (#66)
* docs: fix schema.md icon examples for @sanity/icons v5 subpath imports @sanity/icons v5 (pulled in transitively by sanity ^6.7.0) removed named icon exports from the package root; only the icons map and Icon component remain there, with named icons moved to per-icon subpaths. The root's type declarations still declare the old names (as `never`, with a deprecation note), so the old import style type-checks but crashes Sanity Studio at runtime. Update schema.md's icon import example and content-type table to use the v5 subpath style (e.g. `@sanity/icons/DocumentText`) so agents following this skill don't ship a working build that crashes in the browser. * docs: fix @sanity/icons v5 subpath imports in localization, page-builder, seo refs Same broken root-import pattern fixed in schema.md: @sanity/icons v5 removed named icon exports from the package root, so the old `import { XIcon } from '@sanity/icons'` style type-checks but crashes Sanity Studio at runtime. Update the icon import examples in localization.md, page-builder.md, and seo.md to the v5 per-icon subpath style (e.g. `@sanity/icons/Home`). * docs: trim icon-import explanation to the code examples The mechanism paragraph explained internals an agent never acts on, and claimed the bad import "crashes Studio at runtime". It doesn't — Vite and esbuild both fail the bundle with `"DocumentTextIcon" is not exported by @sanity/icons`, so `sanity build` errors immediately. Keep the ✅/❌ pair and the table's Import column (the parts that change behavior), and correct the failure mode in the ❌ comment. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Rune Botten <rbotten@gmail.com>
1 parent fc0e709 commit dfcdd28

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

skills/sanity-best-practices/references/localization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Don't create nearly identical copies with slight differences (e.g., US vs Britis
4343

4444
```typescript
4545
// schemaTypes/locale.ts
46-
import { TranslateIcon } from '@sanity/icons'
46+
import { TranslateIcon } from '@sanity/icons/Translate'
4747
import { defineField, defineType } from 'sanity'
4848

4949
export const localeType = defineType({
@@ -167,7 +167,7 @@ For singletons like homepages that need a separate document per locale, combine
167167

168168
```typescript
169169
// schemaTypes/homePage.ts
170-
import { HomeIcon } from '@sanity/icons'
170+
import { HomeIcon } from '@sanity/icons/Home'
171171
import { defineType, defineField } from 'sanity'
172172

173173
export const homePageType = defineType({
@@ -237,7 +237,7 @@ Create a helper to show one singleton per locale in the Structure:
237237
```typescript
238238
// src/structure/index.ts
239239
import { StructureBuilder, StructureResolver } from 'sanity/structure'
240-
import { HomeIcon } from '@sanity/icons'
240+
import { HomeIcon } from '@sanity/icons/Home'
241241

242242
const LOCALES = ['en', 'fr', 'de']
243243

skills/sanity-best-practices/references/page-builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Every block should have consistent previews:
7474

7575
```typescript
7676
import { defineType } from "sanity";
77-
import { BlockContentIcon } from "@sanity/icons";
77+
import { BlockContentIcon } from "@sanity/icons/BlockContent";
7878

7979
export const splitImageType = defineType({
8080
name: "splitImage",

skills/sanity-best-practices/references/schema.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Always use the helper functions from `sanity` for type safety and autocompletion
3636

3737
```typescript
3838
import { defineType, defineField, defineArrayMember } from 'sanity'
39-
import { TagIcon } from '@sanity/icons'
39+
import { TagIcon } from '@sanity/icons/Tag'
4040

4141
export const article = defineType({
4242
name: 'article',
@@ -114,17 +114,26 @@ Every item in a Sanity array automatically gets a `_key` property. This is **cri
114114
### B. Icons
115115
Always assign an icon from `@sanity/icons` to documents and objects. This improves the Studio UX significantly. Browse all icons at [icons.sanity.build](https://icons.sanity.build/all).
116116

117-
| Content Type | Icon |
118-
|--------------|------|
119-
| Article, Post | `DocumentTextIcon` |
120-
| Author, Person | `UserIcon` |
121-
| Category, Tag | `TagIcon` |
122-
| Settings | `CogIcon` |
123-
| Page | `DocumentIcon` |
124-
| Image block | `ImageIcon` |
125-
| Video block | `PlayIcon` |
126-
| FAQ | `HelpCircleIcon` |
127-
| Link | `LinkIcon` |
117+
```typescript
118+
// ✅ Correct — import each icon from its own subpath
119+
import { DocumentTextIcon } from '@sanity/icons/DocumentText'
120+
121+
// ❌ Wrong — root named exports were removed in v5.
122+
// Type-checks clean, then fails at bundle time.
123+
import { DocumentTextIcon } from '@sanity/icons'
124+
```
125+
126+
| Content Type | Icon | Import |
127+
|--------------|------|--------|
128+
| Article, Post | `DocumentTextIcon` | `@sanity/icons/DocumentText` |
129+
| Author, Person | `UserIcon` | `@sanity/icons/User` |
130+
| Category, Tag | `TagIcon` | `@sanity/icons/Tag` |
131+
| Settings | `CogIcon` | `@sanity/icons/Cog` |
132+
| Page | `DocumentIcon` | `@sanity/icons/Document` |
133+
| Image block | `ImageIcon` | `@sanity/icons/Image` |
134+
| Video block | `PlayIcon` | `@sanity/icons/Play` |
135+
| FAQ | `HelpCircleIcon` | `@sanity/icons/HelpCircle` |
136+
| Link | `LinkIcon` | `@sanity/icons/Link` |
128137

129138
### C. Boolean vs. List
130139
Avoid boolean fields for binary states that might expand later.

skills/sanity-best-practices/references/seo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Create a redirect document type for content team management.
193193
```typescript
194194
// schemaTypes/redirectType.ts
195195
import { defineField, defineType, SanityDocumentLike } from "sanity";
196-
import { LinkIcon } from "@sanity/icons";
196+
import { LinkIcon } from "@sanity/icons/Link";
197197

198198
function isValidPath(value: string | undefined) {
199199
if (!value) return "Required";

0 commit comments

Comments
 (0)