EmDash는 콘텐츠 스키마를 정의하는 14가지 필드 유형을 지원합니다. 각 유형은 SQLite 열 유형에 매핑되며 적절한 관리 UI를 제공합니다.
Overview
| Type | SQLite Column | Description |
|---|---|---|
string | TEXT | 짧은 한 줄 텍스트 입력 |
text | TEXT | 여러 줄 텍스트 |
number | REAL | 소수 |
integer | INTEGER | 정수 |
boolean | INTEGER | 참 / 거짓 |
datetime | TEXT | 날짜 및 시간 |
select | TEXT | 옵션에서 단일 선택 |
multiSelect | JSON | 다중 선택 |
portableText | JSON | 리치 텍스트 콘텐츠 |
image | TEXT | 이미지 참조 |
file | TEXT | 파일 참조 |
reference | TEXT | 다른 항목 참조 |
json | JSON | 임의의 JSON 데이터 |
slug | TEXT | URL 안전 식별자 |
Text Types
string
짧은 한 줄 텍스트. 제목, 이름, 짧은 값에 사용합니다.
{
slug: "title",
label: "Title",
type: "string",
required: true,
validation: {
minLength: 1,
maxLength: 200,
},
}
Validation options:
minLength— 최소 문자 수maxLength— 최대 문자 수pattern— 일치시킬 정규식 패턴
Widget options:
- 특정 항목 없음
text
여러 줄 일반 텍스트. 설명, 발췌, 긴 일반 텍스트에 사용합니다.
{
slug: "excerpt",
label: "Excerpt",
type: "text",
options: {
rows: 3,
},
}
Validation options:
minLength— 최소 문자 수maxLength— 최대 문자 수
Widget options:
rows— textarea 행 수(기본값: 3)
slug
URL 안전 식별자. 다른 필드에서 자동 생성하거나 수동으로 입력합니다.
{
slug: "slug",
label: "URL Slug",
type: "slug",
required: true,
unique: true,
}
slug는 자동으로 정규화됩니다(소문자, 공백을 하이픈으로, 특수 문자 제거).
Number Types
number
소수. 가격, 평가, 측정값에 사용합니다.
{
slug: "price",
label: "Price",
type: "number",
required: true,
validation: {
min: 0,
max: 999999.99,
},
}
Validation options:
min— 최솟값max— 최댓값
SQLite REAL(64비트 부동소수점)으로 저장.
integer
정수. 수량, 개수, 정렬 값에 사용합니다.
{
slug: "quantity",
label: "Quantity",
type: "integer",
defaultValue: 1,
validation: {
min: 0,
max: 1000,
},
}
Validation options:
min— 최솟값max— 최댓값
SQLite INTEGER로 저장.
boolean
참 또는 거짓. 토글과 플래그에 사용합니다.
{
slug: "featured",
label: "Featured",
type: "boolean",
defaultValue: false,
}
SQLite INTEGER(0 또는 1)로 저장.
Date and Time
datetime
날짜 및 시간. ISO 8601 형식으로 저장.
{
slug: "publishedAt",
label: "Published At",
type: "datetime",
}
Validation options:
min— 최소 날짜(ISO 문자열)max— 최대 날짜(ISO 문자열)
Storage format: 2025-01-24T12:00:00.000Z
Selection Types
select
미리 정의된 옵션에서 단일 선택.
{
slug: "status",
label: "Status",
type: "select",
required: true,
defaultValue: "draft",
validation: {
options: ["draft", "published", "archived"],
},
}
Validation options:
options— 허용 값 배열(필수)
선택한 값이 담긴 TEXT로 저장.
multiSelect
미리 정의된 옵션에서 다중 선택.
{
slug: "tags",
label: "Tags",
type: "multiSelect",
validation: {
options: ["news", "tutorial", "review", "opinion"],
},
}
Validation options:
options— 허용 값 배열(필수)
JSON 배열로 저장: ["news", "tutorial"]
Rich Content
portableText
Portable Text 형식의 리치 텍스트. 제목, 목록, 링크, 이미지, 사용자 정의 블록을 지원합니다.
{
slug: "content",
label: "Content",
type: "portableText",
required: true,
}
Portable Text 블록의 JSON 배열로 저장:
[
{
"_type": "block",
"style": "normal",
"children": [{ "_type": "span", "text": "Hello world" }]
}
]
플러그인은 편집기에 사용자 정의 블록 유형(임베드, 위젯 등)을 추가할 수 있습니다. 슬래시 명령 메뉴에 표시되며 사이트에서 자동으로 렌더링됩니다. 참고: Creating Plugins — Portable Text Block Types.
Media Types
image
업로드된 이미지 참조. 크기 및 alt 텍스트 등 메타데이터를 포함합니다.
{
slug: "featuredImage",
label: "Featured Image",
type: "image",
options: {
showPreview: true,
},
}
Widget options:
showPreview— 관리자에서 이미지 미리보기 표시(기본값: true)
Stored value:
{
"id": "01HXK5MZSN...",
"url": "https://cdn.example.com/image.jpg",
"alt": "Description",
"width": 1920,
"height": 1080
}
file
업로드된 파일(문서, PDF 등) 참조.
{
slug: "document",
label: "Document",
type: "file",
}
Stored value:
{
"id": "01HXK5MZSN...",
"url": "https://cdn.example.com/doc.pdf",
"filename": "report.pdf",
"mimeType": "application/pdf",
"size": 102400
}
Relational Types
reference
다른 콘텐츠 항목 참조.
{
slug: "author",
label: "Author",
type: "reference",
required: true,
options: {
collection: "authors",
},
}
Widget options:
collection— 대상 컬렉션 slug(필수)allowMultiple— 여러 참조 허용(기본값: false)
Single reference stored value:
"01HXK5MZSN..."
Multiple references stored value:
["01HXK5MZSN...", "01HXK6NATS..."]
Flexible Types
json
임의의 JSON 데이터. 중첩 구조, 서드파티 연동, 고정 스키마가 없는 데이터에 사용합니다.
{
slug: "metadata",
label: "Metadata",
type: "json",
}
SQLite JSON 열에 그대로 저장.
Field Properties
모든 필드에서 다음 공통 속성을 사용할 수 있습니다:
| Property | Type | Description |
|---|---|---|
slug | string | 고유 식별자(필수) |
label | string | 표시 이름(필수) |
type | FieldType | 필드 유형(필수) |
required | boolean | 값 필수(기본값: false) |
unique | boolean | 고유성 강제(기본값: false) |
defaultValue | unknown | 새 항목의 기본값 |
validation | object | 유형별 유효성 검사 규칙 |
widget | string | 사용자 정의 위젯 재정의 |
options | object | 위젯 구성 |
sortOrder | number | 관리자에서의 표시 순서 |
Reserved Field Slugs
다음 slug는 예약되어 사용할 수 없습니다:
idslugstatusauthor_idcreated_atupdated_atpublished_atdeleted_atversion
TypeScript Types
프로그래밍 방식 사용을 위해 필드 유형 가져오기:
import type { FieldType, Field, CreateFieldInput } from "emdash";
const fieldTypes: FieldType[] = [
"string",
"text",
"number",
"integer",
"boolean",
"datetime",
"select",
"multiSelect",
"portableText",
"image",
"file",
"reference",
"json",
"slug",
];