[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,91 +2,223 @@
|
||||
id: wiki-2026-0508-sanity-studio
|
||||
title: Sanity Studio
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Sanity, Sanity CMS, Sanity Headless]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [headless-cms, sanity, content, structured-content]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: TypeScript
|
||||
framework: Sanity v3 + React
|
||||
---
|
||||
|
||||
# [[Sanity Studio|Sanity Studio]]
|
||||
# Sanity Studio
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
Sanity Studio는 실시간 협업 콘텐츠 편집기(real-time collaborative content editor)입니다 [1]. 복잡한 폼(form) 편집기와 깊게 중첩된 업데이트 패턴을 갖춘 컴포넌트들로 구성되어 있는 것이 특징입니다 [1]. 본 문서의 주요 초점 외의 구체적인 플랫폼 기능에 대해서는 소스에 관련 정보가 부족합니다.
|
||||
## 매 한 줄
|
||||
> **"매 Sanity Studio는 customizable single-page editor 를 wrap 한 headless CMS"**. v3 (2023) 부터 React 기반 fully composable, 매 schema-as-code (TS), GROQ query language, Portable Text, real-time collaboration. 2026 기준 Contentful / Strapi 의 main alternative — 매 dev experience + customization 이 강점.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **[[React Compiler|React Compiler]] 적용 및 렌더링 성능 향상:** Sanity Studio는 React Compiler를 애플리케이션에 도입하여 렌더링 시간을 20~30% 단축하는 데 성공했습니다 [1, 2].
|
||||
- **지연 시간 개선 및 수동 메모이제이션 제거:** 컴파일러 도입을 통해 복잡한 폼 편집기에서 발생하던 지연 시간(latency)을 크게 개선했습니다 [1]. 특히 과거에는 개발자가 세심하게 수동으로 메모이제이션(manual memoization)을 처리해야만 했던 깊게 중첩된 컴포넌트 업데이트 패턴들이 컴파일러를 통해 별다른 조치 없이 자동으로 최적화되었습니다 [1].
|
||||
- **엔지니어링 생산성 증가:** 성능 최적화와 디버깅에 소요되던 시간이 줄어들면서 엔지니어링 팀은 즉각적인 생산성 향상 효과를 얻을 수 있었습니다 [1].
|
||||
- (※ 소스에 관련 정보가 부족합니다. 제공된 자료에서는 Sanity Studio를 'React Compiler 성능 개선을 입증하는 케이스 스터디'의 용도로만 제한적으로 다루고 있습니다.)
|
||||
## 매 핵심
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[React Compiler|React Compiler]], Manual Memoization
|
||||
- **Projects/Contexts:** [[React Performance Optimization|React Performance Optimization]]
|
||||
- **Contradictions/Notes:** 소스에 관련 정보가 부족합니다. Sanity Studio 자체의 아키텍처나 전반적인 제품군에 대한 설명은 없으며, 오직 React Compiler 도입을 통해 렌더링 속도 개선 및 수동 메모이제이션 부담을 해결한 성공 사례로만 언급됩니다 [1, 2].
|
||||
### 매 컴포넌트
|
||||
- **Studio**: editor SPA (React, self-host or Sanity hosted)
|
||||
- **Content Lake**: cloud datastore (도큐먼트 store)
|
||||
- **GROQ**: query language (graph + projection)
|
||||
- **Portable Text**: rich text JSON spec
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-25*
|
||||
### 매 schema 방식
|
||||
- TS 로 schema 정의 → studio UI 자동 생성
|
||||
- Field type: string, number, image, reference, array, object, slug, portable text...
|
||||
- Custom input component 도 React 로 작성 가능
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. Marketing sites (Next.js + Sanity).
|
||||
2. Editorial / publishing (long-form, structured).
|
||||
3. E-commerce content (product copy, lookbooks).
|
||||
4. Multi-channel content (web + mobile + email).
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### Schema 정의
|
||||
```typescript
|
||||
// schemas/post.ts
|
||||
import { defineType, defineField } from "sanity";
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
export const post = defineType({
|
||||
name: "post",
|
||||
title: "Post",
|
||||
type: "document",
|
||||
fields: [
|
||||
defineField({ name: "title", type: "string", validation: (R) => R.required() }),
|
||||
defineField({
|
||||
name: "slug",
|
||||
type: "slug",
|
||||
options: { source: "title", maxLength: 96 },
|
||||
}),
|
||||
defineField({ name: "author", type: "reference", to: [{ type: "author" }] }),
|
||||
defineField({ name: "body", type: "array", of: [{ type: "block" }, { type: "image" }] }),
|
||||
defineField({ name: "publishedAt", type: "datetime" }),
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### sanity.config.ts
|
||||
```typescript
|
||||
import { defineConfig } from "sanity";
|
||||
import { structureTool } from "sanity/structure";
|
||||
import { visionTool } from "@sanity/vision";
|
||||
import { post, author } from "./schemas";
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
export default defineConfig({
|
||||
name: "default",
|
||||
title: "My Studio",
|
||||
projectId: process.env.SANITY_PROJECT_ID!,
|
||||
dataset: "production",
|
||||
plugins: [structureTool(), visionTool()],
|
||||
schema: { types: [post, author] },
|
||||
});
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### GROQ query
|
||||
```typescript
|
||||
import { createClient } from "@sanity/client";
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
const client = createClient({
|
||||
projectId: process.env.SANITY_PROJECT_ID!,
|
||||
dataset: "production",
|
||||
apiVersion: "2026-01-01",
|
||||
useCdn: true,
|
||||
});
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
const posts = await client.fetch<Post[]>(`
|
||||
*[_type == "post" && publishedAt < now()] | order(publishedAt desc) [0...10] {
|
||||
_id, title, slug, publishedAt,
|
||||
"authorName": author->name,
|
||||
"image": mainImage.asset->url
|
||||
}
|
||||
`);
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Next.js 15 integration with revalidate
|
||||
```typescript
|
||||
// app/posts/[slug]/page.tsx
|
||||
import { client } from "@/lib/sanity";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export const revalidate = 60;
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params;
|
||||
const post = await client.fetch(
|
||||
`*[_type == "post" && slug.current == $slug][0]`,
|
||||
{ slug },
|
||||
{ next: { tags: [`post:${slug}`] } },
|
||||
);
|
||||
if (!post) notFound();
|
||||
return <article>{post.title}</article>;
|
||||
}
|
||||
```
|
||||
|
||||
### On-demand revalidation via webhook
|
||||
```typescript
|
||||
// app/api/revalidate/route.ts
|
||||
import { revalidateTag } from "next/cache";
|
||||
import { parseBody } from "next-sanity/webhook";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const { isValidSignature, body } = await parseBody<{ slug: string; _type: string }>(
|
||||
req, process.env.SANITY_REVALIDATE_SECRET!,
|
||||
);
|
||||
if (!isValidSignature) return Response.json({ ok: false }, { status: 401 });
|
||||
if (body?._type === "post") revalidateTag(`post:${body.slug}`);
|
||||
return Response.json({ ok: true });
|
||||
}
|
||||
```
|
||||
|
||||
### Portable Text rendering
|
||||
```tsx
|
||||
import { PortableText, type PortableTextComponents } from "@portabletext/react";
|
||||
|
||||
const components: PortableTextComponents = {
|
||||
types: {
|
||||
image: ({ value }) => <img src={value.asset.url} alt={value.alt} />,
|
||||
},
|
||||
marks: {
|
||||
link: ({ value, children }) => <a href={value.href}>{children}</a>,
|
||||
},
|
||||
};
|
||||
|
||||
export function Body({ value }: { value: any }) {
|
||||
return <PortableText value={value} components={components} />;
|
||||
}
|
||||
```
|
||||
|
||||
### Custom input component
|
||||
```tsx
|
||||
// schemas/inputs/EmojiInput.tsx
|
||||
import { TextInput, Card } from "@sanity/ui";
|
||||
import { set, unset } from "sanity";
|
||||
|
||||
export function EmojiInput(props: any) {
|
||||
return (
|
||||
<Card padding={2}>
|
||||
<TextInput
|
||||
value={props.value || ""}
|
||||
onChange={(e) =>
|
||||
props.onChange(e.currentTarget.value ? set(e.currentTarget.value) : unset())
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### TypeGen for type-safe queries
|
||||
```bash
|
||||
npx sanity@latest typegen generate
|
||||
# generates sanity.types.ts with full TS types per query
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Dev-first, code-driven schema | Sanity |
|
||||
| Non-tech editor, off-the-shelf | Contentful / Storyblok |
|
||||
| Self-host, full control | Strapi / Payload |
|
||||
| 매 real-time collab + custom UI | Sanity (강점) |
|
||||
| Tiny site / blog | MDX in repo (overkill 회피) |
|
||||
|
||||
**기본값**: Sanity v3 + Next.js 15 + GROQ + Portable Text + TypeGen.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Headless CMS]] · [[Content Management]]
|
||||
- 변형: [[Contentful]] · [[Strapi]] · [[Payload CMS]] · [[Storyblok]]
|
||||
- 응용: [[Marketing Site]] · [[Editorial Platform]]
|
||||
- Adjacent: [[GROQ]] · [[Portable Text]] · [[Next.js ISR]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: Marketing / editorial site, 매 dev-driven schema, custom editor needs. 매 Next.js + cloud CMS 의 경우.
|
||||
**언제 X**: Tiny static blog (MDX 충분), enterprise with strict on-prem.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **`useCdn: true` for drafts**: preview 모드에서 매 stale data. Preview 시 false.
|
||||
- **Naked GROQ in components**: 매 query 를 lib/queries.ts 로 모으고 typegen.
|
||||
- **No webhook revalidation**: 매 시간 단위 revalidate 만 → editor 답답함. On-demand webhook 필수.
|
||||
- **Schema in studio UI**: 매 schema-as-code 가 v3 의 핵심. 매 GUI 편집 X.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (sanity.io docs v3, 2026).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Sanity Studio full content |
|
||||
|
||||
Reference in New Issue
Block a user