본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)8.1k · #12598

webiny-api-cms-content-models

하는 일

이 스킬은 Webiny 프로젝트에서 CMS 콘텐츠 모델을 코드로 만들거나 바꿀 때 AI를 안내합니다. 데이터 구조를 버전 관리되는 코드로 정의하려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓제품이나 블로그 글 같은 콘텐츠 모델을 코드로 만들고 싶을 때.
  • ✓필드에 검증이나 다른 모델을 향한 참조가 필요할 때.
  • ✓필드 유형마다 관리자에서 어떤 표시 방식을 쓸지 골라야 하는 경우.

스킬 링크

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/content-models/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/content-models/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이름, 가격 필드와 카테고리 모델을 참조하는 필드가 있는 제품 콘텐츠 모델을 코드로 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 연결형 빌더로 필드, 레이아웃, 제목 필드, API 이름을 선언하는 모델 클래스를 보여 줍니다. 모델은 프로젝트의 설정 파일에 등록됩니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Creating Content Models via Code

TL;DR

Content models are created using the ModelFactory pattern. You define a class implementing ModelFactory.Interface, use the fluent ModelFactory.Builder API to declare fields, validators, layout, and API names, then export with ModelFactory.createImplementation(). Register in webiny.config.tsx as <Api.Extension>.

The ModelFactory Pattern

Every code-based content model follows the same structure:

import { ModelFactory } from "webiny/api/cms/model";

class MyModelImpl implements ModelFactory.Interface {
  async execute(builder: ModelFactory.Builder) {
    return [
      builder
        .public({ modelId: "myModel", name: "My Model", group: "ungrouped" })
        .description("Description of the model")
        .fields(fields => ({
          // field definitions here
        }))
        .layout([/* row definitions */])
        .titleFieldId("fieldId")
        .singularApiName("MyModel")
        .pluralApiName("MyModels")
    ];
  }
}

export default ModelFactory.createImplementation({
  implementation: MyModelImpl,
  dependencies: []
});

Register in webiny.config.tsx:

<Api.Extension src={"/extensions/MyModel.ts"} />

YOU MUST include the full file path with the .ts extension in the src prop. For example, use src={"/extensions/MyModel.ts"}, NOT src={"/extensions/MyModel"}. Omitting the file extension will cause a build failure.

YOU MUST use export default for the createImplementation() call when the file is targeted directly by an Extension src prop. Using a named export (export const MyModel = ...) will cause a build failure. Named exports are only valid inside files registered via createFeature.

Model Configuration Methods

Method Purpose
.public({ modelId, name, group }) Creates a public model (accessible via Read API). modelId is the internal DB identifier. group organizes it in the Admin sidebar.
.description("...") Model description shown in Admin UI
.fields(fields => ({ ... })) Define all fields using the fluent field builder
.layout([["field1", "field2"], ["field3"]]) Arrange fields in rows in the Admin editor. Each inner array is one row.
.titleFieldId("name") Which field to use as the entry's display title
.descriptionFieldId("message") Which field to use as the entry's description
.singularApiName("Product") Singular name for GraphQL queries (e.g., getProduct)
.pluralApiName("Products") Plural name for GraphQL queries (e.g., listProducts)
.singleEntry() Makes the model a singleton (only one entry can exist). Automatically adds
자주 묻는 질문

모델은 어떻게 등록하나요?

webiny 설정 파일에 API 확장 기능으로 등록하며, .ts 확장자를 포함한 전체 파일 경로를 씁니다.

필드를 중첩할 수 있나요?

네. 객체 필드와 동적 영역 필드 안의 중첩 레이아웃을 다룹니다.

필드 표시 유형을 고르는 방법도 다루나요?

네. 필드 유형마다 어떤 관리자 표시를 써야 하는지 설명합니다.

상세 정보

작성자의 원본 설명

Creating Headless CMS content models via code using the ModelFactory pattern. Use this skill when the developer wants to create, modify, or understand content model definitions, define fields and validators, set up reference fields between models, configure field layouts (including nested layouts inside object or dynamicZone fields), pick the correct Admin UI renderer for a field type (textInput/textInputs, lexicalEditor/lexicalEditors, file/files, objectAccordionSingle/objectAccordionMultiple, etc.), or work with the ModelFactory builder API. Also covers field types (text, longText, number, b

repo: webiny/webiny-js

인기도

GitHub 스타
8.1k
순위
#12598
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬