콘텐츠로 이동

5. ACF 블록 명세

BreezeBio 테마는 ACF Pro를 사용하여 19개의 커스텀 블록을 제공합니다. 각 블록은 Twig 템플릿과 Svelte 컴포넌트로 구성됩니다.

BlockRegistrar 클래스가 blocks/ 디렉토리의 모든 블록을 자동으로 등록합니다.

src/Blocks/BlockRegistrar.php
class BlockRegistrar
{
public function init(): void
{
add_action('init', [$this, 'registerBlocks']);
}
public function registerBlocks(): void
{
$blocksDir = get_stylesheet_directory() . '/blocks';
foreach (glob($blocksDir . '/*/block.json') as $blockJson) {
register_block_type(dirname($blockJson));
}
}
}

#블록 ID이름Svelte설명
1genedit-heroHero Section메인 히어로 (전체 화면)
2genedit-page-heroPage Hero서브페이지 히어로
3genedit-section-titleSection Title섹션 제목
4genedit-feature-cardsFeature Cards특징 카드 그리드
5genedit-image-textImage Text이미지+텍스트 레이아웃
6genedit-two-column-textTwo Column Text2단 텍스트
7genedit-cta-bannerCTA BannerCall-to-Action 배너
8genedit-testimonialsTestimonials인용/후기 슬라이더
9genedit-partnersPartners파트너사 로고
10genedit-investorsInvestors투자사 로고
11genedit-teamTeam팀 멤버 (동적)
12genedit-newsNews뉴스 목록 (동적)
13genedit-careersCareers채용 정보
14genedit-qaQ&AFAQ 아코디언
15genedit-content-accordionContent Accordion일반 아코디언
16genedit-pipeline-tablePipeline Table파이프라인 테이블
17genedit-program-sectionProgram Section프로그램 섹션
18genedit-program-detailProgram Detail프로그램 상세
19genedit-contact-infoContact Info연락처 정보

blocks/genedit-hero/
├── block.json # 블록 메타데이터 + ACF 설정
├── render.twig # Twig 렌더 템플릿
└── HeroSection.svelte # Svelte 컴포넌트
{
"name": "genedit-hero",
"title": "Hero Section",
"description": "Full-screen hero section with background image",
"category": "genedit",
"icon": "cover-image",
"keywords": ["hero", "banner", "header"],
"acf": {
"mode": "preview"
},
"supports": {
"anchor": true,
"align": ["full", "wide"],
"alignWide": true
},
"attributes": {
"align": {
"type": "string",
"default": "full"
}
}
}
{# blocks/genedit-hero/render.twig #}
{% set block_id = block.id %}
{% set block_class = 'genedit-hero ' ~ (block.className ?? '') %}
<div id="{{ block_id }}" class="{{ block_class }}">
<div data-svelte="genedit-hero"
data-title="{{ fields.title|e('html_attr') }}"
data-highlight="{{ fields.highlight_text|e('html_attr') }}"
data-image="{{ fields.background_image.url|e('html_attr') }}">
{# SEO 폴백 콘텐츠 #}
<div class="seo-content">
<h1>{{ fields.title }}</h1>
{% if fields.highlight_text %}
<span>{{ fields.highlight_text }}</span>
{% endif %}
</div>
</div>
</div>
blocks/genedit-hero/HeroSection.svelte
<script>
let { title, highlight, image } = $props();
</script>
<section class="hero relative h-screen">
<img src={image} alt="" class="absolute inset-0 object-cover" />
<div class="relative z-10 flex items-center justify-center h-full">
<div class="text-center text-white">
{#if highlight}
<span class="badge">{highlight}</span>
{/if}
<h1 class="text-6xl font-display">{title}</h1>
</div>
</div>
</section>

메인 페이지 전체 화면 히어로.

필드타입필수설명
titleText메인 제목
highlight_textText강조 뱃지 텍스트
background_imageImage배경 이미지
background_videoFile배경 비디오 (선택)

팀 멤버를 동적으로 불러오는 블록.

필드타입필수설명
descriptionWYSIWYG섹션 설명

특별 처리: GeneditSite::addTeamBlockContext()에서 팀 멤버 데이터를 자동 주입합니다.

public function addTeamBlockContext(array $context): array
{
$context['team_tabs'] = TeamMemberQuery::getTeamTabs();
return $context;
}

최신 뉴스를 동적으로 불러오는 블록.

필드타입필수설명
titleText섹션 제목
countNumber표시할 개수 (기본: 3)
categoryTaxonomy특정 카테고리 필터

ACF 필드 정의는 acf-json/ 디렉토리에 JSON으로 저장됩니다.

acf-json/
├── group_hero.json
├── group_team_member.json
├── group_contact_form.json
└── ...
  • 저장: 관리자에서 필드 그룹 저장 시 자동으로 JSON 파일 생성
  • 로드: 테마 활성화 시 JSON 파일에서 필드 그룹 로드
GeneditSite.php
public function acfJsonSavePath(): string
{
return get_stylesheet_directory() . '/acf-json';
}
public function acfJsonLoadPaths(array $paths): array
{
unset($paths[0]);
$paths[] = get_stylesheet_directory() . '/acf-json';
return $paths;
}

Terminal window
$ ddev npm run create:block

대화형으로 블록 이름을 입력하면 기본 구조가 생성됩니다.

  1. blocks/genedit-{name}/ 디렉토리 생성
  2. block.json 작성
  3. render.twig 작성
  4. {Name}.svelte 작성
  5. ACF 필드 그룹 생성 (관리자에서)

모든 Svelte 블록은 .seo-content 클래스를 포함해야 합니다.

<div data-svelte="component-name">
{# Svelte 마운트 후 숨겨지는 SEO 콘텐츠 #}
<div class="seo-content">
<h2>{{ fields.title }}</h2>
<p>{{ fields.content }}</p>
</div>
</div>
  1. 초기 로드: Twig가 .seo-content 렌더링 (검색엔진 크롤링)
  2. JS 로드: Svelte 마운트
  3. 마운트 완료: .seo-contenthidden 클래스 추가

← 이전: 4. 테마 구조 | 다음: 6. 커스텀 모듈 →