[refactor] solution,nginx: 에디터와 발행본을 한 렌더러로 — 보는 그대로 나간다

에디터에서 본 화면과 발행된 화면이 달랐다. 렌더러를 두 벌 들고 있었기 때문이다 —
캔버스는 `builder/canvas/variants/*` 25종, 발행본은 `site/src/sections/*`.
Playwright 로 재 보니 아예 다른 물건이었다(2026-09-09, 1024px):

  발행본 15섹션 · 에디터 12섹션 · 겹치는 건 4개뿐, 이름도 달랐다
  (gallery↔photos · location↔map · guide↔local)
  겹치는 4개조차 높이가 달랐다(info 488↔535 · booking 242↔487 · itinerary 881↔383)

소스를 하나로 모은다. 편집·미리보기 둘 다 발행본 렌더러가 그린다.

**데이터도 한 벌** — `GET /v1/place/{id}/site/preview` 가 발행이 굽는 것과 **같은 함수**
(`build_snapshot` → `to_site_payload`)로 payload 를 만든다. DB 도 파일도 건드리지 않는다.

**왜 iframe 인가** — 컴포넌트만 같게 해서는 안 됐다. 미디어 쿼리는 창 폭을 보는데 실제
사이트 폭은 그 안의 프레임이라, 그리드 컬럼 수가 어긋나 섹션이 두 배씩 길어졌다
(festival 2560→6027 · guide 1168→2168). iframe 은 자체 뷰포트를 가져 발행본과 같은 폭을 본다.
폭만이 아니라 **높이도** 준다 — 히어로가 `clamp(24rem, 62vh, 36rem)` 이라 낮은 iframe 에서는
하한에 걸렸다(384 ↔ 발행본 576). 자리에 안 들어가면 transform 으로 줄인다: 크기는 그대로,
그림만 줄여야 미디어 쿼리가 안 흔들린다.

**색·서체도 한 벌** — `themeVars(payload)` · `fontHref(payload)`. 셸에는 발행본 `<head>` 의
폰트 링크가 없어 글자만 기본 산세리프로 떨어졌다(지오메트리는 같은데 픽셀 차이 92%).

**에디터가 저장된 템플릿을 안 읽던 것** — `applyTheme` 이 섹션·색팔레트는 되살리는데
templateId 를 빠뜨렸다. templateId 는 theme JSON 이 아니라 `sites.template_id` **컬럼**이라
저장 경로가 다른데 읽는 쪽이 theme 만 봤다. 사장님이 '옛 항구' 를 골라 발행해도 다시
들어오면 편집 화면만 흰 바탕·고딕이었다.

**고르기는 iframe 안에서** — 같은 오리진이라 안쪽 문서에 직접 리스너를 건다. 어느 섹션인지는
`data-editor-id` 로 안다(화면 id `gallery` ↔ 설정 id `photos`; `display:contents` 라 레이아웃
무영향). 표시는 outline 이다 — 상자 크기를 바꾸지 않아 발행본과 픽셀이 그대로다.

곁들여 정리한 것
- 켤 수 없는 섹션 둘(`pricing`·`planner`)을 뗐다 — 기본표에도 [+섹션 추가]에도 없고 DB 참조 0건.
- 반대로 `event`(소식)는 기본표가 켜서 **발행되는데** 채울 UI 가 없었다. 명세를 넣는다.
  이 아이템만 프롬프트가 "찾아라" 가 아니라 **"옮겨 적어라"** 다 — 이 가게에서 지금 하는
  일이라 모델이 알 수 없고, 지어내면 손님이 없는 행사를 보고 찾아온다.
- 예약 버튼이 "네이버 예약 예약" 이었다. `{bookingLabel} 예약` 을 13개 파일에서 각자 이어
  붙이고 있었다 — `bookingActionLabel()` 하나로 모은다.
- `solution/site` 의 별칭을 `@` → `@site` 로 옮겼다(60파일 195건). 두 앱이 '@' 를 각자 자기
  src 로 두면 발행본 컴포넌트를 빌더에서 부를 때 **조용히 다른 파일을 잡는다.**

검증(Playwright, 같은 사업장·1024px):
  섹션 15 = 15 · 순서 일치 · **한쪽에만 있는 섹션 0개**
  15개 전부 높이·글자 수·제목이 정확히 같다
  편집·미리보기·발행본 셋 다 --tpl-bg #e4dac0 · Gugi
  `/preview` ↔ 발행본 문서 높이 9029 = 9029, 픽셀 차이 2.88%(축제 카드 지연 로딩 타이밍)
tsc -b 통과 · eslint 통과.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 5 committed 2026-09-09 17:09:28 +09:00
1 parent 387783b766
commit b1386dd3ce
77 files changed
+710 -585

No files matched your search

+5 -5
View File
@@ -1,7 +1,7 @@
import {useSite} from '@/lib/site-context';
import {primaryImage} from '@/seo/meta';
import {useSite} from '@site/lib/site-context';
import {primaryImage} from '@site/seo/meta';
import {
bookingLabel,
bookingActionLabel,
bookingLinks,
contactLinks,
channelLabel,
@@ -9,7 +9,7 @@ import {
lowestPrice,
unitSpec,
unitViews,
} from '@/lib/derive';
} from '@site/lib/derive';
import {GRAIN} from './SectionHead';
/**
@@ -117,7 +117,7 @@ export function Hero() {
rel="noopener noreferrer"
className="tap inline-flex items-center underline underline-offset-4"
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
{place.phone && (
@@ -1,13 +1,13 @@
import type {ChannelLink} from '@o2o/shared';
import {useSite} from '@/lib/site-context';
import {useSite} from '@site/lib/site-context';
import {
bookingLabel,
bookingActionLabel,
bookingLinks,
sectionName,
unitSpec,
unitViews,
type UnitView,
} from '@/lib/derive';
} from '@site/lib/derive';
import {GRAIN, SectionHead} from './SectionHead';
/**
@@ -153,7 +153,7 @@ function UnitSpread({
rel="noopener noreferrer"
className="tap inline-flex items-center underline underline-offset-4"
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
{phone && (
@@ -1,6 +1,6 @@
import type {ReactNode} from 'react';
import {useSite} from '@/lib/site-context';
import {enabledSections, unitSpec} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {enabledSections, unitSpec} from '@site/lib/derive';
/**
* 편집(잡지)형 — 섹션 제목 · 차례.
@@ -1,9 +1,9 @@
import {useEffect, useState, type ReactNode} from 'react';
import {useSite} from '@/lib/site-context';
import {bookingLabel, bookingLinks, channelLabel} from '@/lib/derive';
import {formatKoreanDate, isoDate} from '@/lib/format';
import {useSite} from '@site/lib/site-context';
import {bookingActionLabel, bookingLinks, channelLabel} from '@site/lib/derive';
import {formatKoreanDate, isoDate} from '@site/lib/format';
// 배럴(@/sections)이 아니라 파일을 직접 가리킨다 — 배럴을 타면 섹션 전부가 딸려 온다.
import {MobileTabBar} from '@/sections/MobileTabBar';
import {MobileTabBar} from '@site/sections/MobileTabBar';
import {GRAIN, useSectionIndex, type IndexEntry} from './SectionHead';
/**
@@ -60,7 +60,7 @@ export function Shell({children}: {children: ReactNode}) {
rel="noopener noreferrer"
className="tap inline-flex items-center font-bold underline underline-offset-4"
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
</div>
+4 -4
View File
@@ -1,6 +1,6 @@
import {useSite} from '@/lib/site-context';
import {primaryImage} from '@/seo/meta';
import {bookingLabel, bookingLinks, essentialRows, heroFacts, lowestPrice} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {primaryImage} from '@site/seo/meta';
import {bookingActionLabel, bookingLinks, essentialRows, heroFacts, lowestPrice} from '@site/lib/derive';
/**
* oasi 첫 화면 — 사진 한 장과 아주 작은 글씨.
@@ -98,7 +98,7 @@ export function Hero() {
className="tap inline-flex items-center text-[length:var(--fs-sm)] underline underline-offset-[6px]"
style={{color: 'var(--color-brand)'}}
>
{bookingLabel(link)} 예약
{bookingActionLabel(link)}
</a>
</li>
))}
+3 -3
View File
@@ -1,5 +1,5 @@
import {useSite} from '@/lib/site-context';
import {bookingLabel, bookingLinks, sectionName, unitSpec, unitViews} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {bookingActionLabel, bookingLinks, sectionName, unitSpec, unitViews} from '@site/lib/derive';
import {SectionHead} from './SectionHead';
/**
@@ -116,7 +116,7 @@ export function Rooms() {
className="tap inline-flex items-center underline underline-offset-[6px]"
style={{color: 'var(--color-brand)'}}
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
{payload.place.phone && (
+6 -5
View File
@@ -1,17 +1,18 @@
import type {CSSProperties, ReactNode} from 'react';
import {isoDate} from '@/lib/format';
import {useSite} from '@/lib/site-context';
import {isoDate} from '@site/lib/format';
import {useSite} from '@site/lib/site-context';
import {
bookingActionLabel,
bookingLabel,
bookingLinks,
contactLinks,
heroFacts,
isSectionEnabled,
unitSpec,
} from '@/lib/derive';
} from '@site/lib/derive';
// ★ 배럴(`@/sections`)을 거치면 껍데기 하나가 사이트의 모든 섹션을 끌고 들어온다.
// 껍데기는 하단 고정 바 하나만 필요하다 — 파일을 직접 가리킨다.
import {MobileTabBar} from '@/sections/MobileTabBar';
import {MobileTabBar} from '@site/sections/MobileTabBar';
/**
* 본문 섹션의 색 띠를 걷어낸다 (2026-09-04, 사장님 지적).
@@ -299,7 +300,7 @@ export function Shell({children}: {children: ReactNode}) {
className="tap mt-2 inline-flex items-center text-[length:var(--fs-sm)] underline underline-offset-[6px]"
style={{color: 'var(--color-brand)'}}
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
</header>
+3 -3
View File
@@ -1,5 +1,5 @@
import {useSite} from '@/lib/site-context';
import {bookingLabel, bookingLinks, heroFacts, lowestPrice} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {bookingActionLabel, bookingLinks, heroFacts, lowestPrice} from '@site/lib/derive';
/**
* 파스텔의 첫 화면 — **연노랑 판 위에 둥근 사진**.
@@ -99,7 +99,7 @@ export function Hero() {
className="tap mt-7 inline-flex items-center justify-center rounded-full px-8 text-[length:var(--fs-sm)] font-extrabold transition-opacity hover:opacity-90"
style={{backgroundColor: 'var(--pastel-ink)', color: 'var(--tpl-bg, #fff)'}}
>
{bookingLabel(links[0])}로 예약
{bookingActionLabel(links[0])}
</a>
)}
</div>
+3 -3
View File
@@ -1,6 +1,6 @@
import {ChevronDown, Phone} from 'lucide-react';
import {useSite} from '@/lib/site-context';
import {bookingLabel, bookingLinks, sectionName, unitSpec, unitViews} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {bookingActionLabel, bookingLinks, sectionName, unitSpec, unitViews} from '@site/lib/derive';
import {SectionHead} from './SectionHead';
/**
@@ -112,7 +112,7 @@ export function Rooms() {
className="tap flex flex-1 items-center justify-center rounded-full text-[length:var(--fs-sm)] font-extrabold transition-opacity hover:opacity-90"
style={{backgroundColor: 'var(--pastel-ink)', color: 'var(--tpl-bg, #fff)'}}
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
{payload.place.phone && (
+4 -4
View File
@@ -1,11 +1,11 @@
import type {CSSProperties, ReactNode} from 'react';
import {Instagram, Menu, MessageCircle, Phone} from 'lucide-react';
import {useSite} from '@/lib/site-context';
import {channelLabel, contactLinks, isSectionEnabled, unitSpec} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {channelLabel, contactLinks, isSectionEnabled, unitSpec} from '@site/lib/derive';
// ★ 배럴(@/sections)로 들어가면 UnitsSection → layouts/pastel/Rooms 로 돌아와 순환 참조다.
// 쓰는 파일을 직접 가리킨다.
import {SiteFooter} from '@/sections/SiteFooter';
import {MobileTabBar} from '@/sections/MobileTabBar';
import {SiteFooter} from '@site/sections/SiteFooter';
import {MobileTabBar} from '@site/sections/MobileTabBar';
/**
* 파스텔 — 색면(色面) 블록형 껍데기.
@@ -1,5 +1,5 @@
import {useSite} from '@/lib/site-context';
import {bookingLabel, bookingLinks, unitSpec} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {bookingLabel, bookingLinks, unitSpec} from '@site/lib/derive';
/**
* 예약형 첫 화면 — 사진이 화면을 채우고 저절로 넘어가며, 정중앙에 이름이 선다.
@@ -1,13 +1,13 @@
import {useSite} from '@/lib/site-context';
import {useSite} from '@site/lib/site-context';
import {
bookingLabel,
bookingActionLabel,
bookingLinks,
essentialRows,
isSectionEnabled,
sectionName,
unitSpec,
unitViews,
} from '@/lib/derive';
} from '@site/lib/derive';
import {SectionHead} from './SectionHead';
/**
@@ -175,7 +175,7 @@ export function Rooms() {
rel="noopener noreferrer"
className="tap border-line inline-flex items-center justify-center border px-9 text-[length:var(--fs-sm)] font-light tracking-[0.14em] transition-opacity hover:opacity-70"
>
{bookingLabel(booking)} 예약
{bookingActionLabel(booking)}
</a>
)}
{payload.place.phone && (
@@ -1,5 +1,5 @@
import {useEffect, useState, type ReactNode} from 'react';
import {useSite} from '@/lib/site-context';
import {useSite} from '@site/lib/site-context';
import {
bookingLabel,
bookingLinks,
@@ -7,11 +7,11 @@ import {
isSectionEnabled,
sectionName,
unitSpec,
} from '@/lib/derive';
import {formatKoreanDate, isoDate} from '@/lib/format';
} from '@site/lib/derive';
import {formatKoreanDate, isoDate} from '@site/lib/format';
// ★ `@/sections` 배럴이 아니라 파일을 직접 가리킨다. 배럴은 섹션 전부를 끌고 오는데,
// 그 안의 UnitsSection 이 이 폴더의 Rooms 를 다시 부른다 — 배럴을 타면 순환이 된다.
import {MobileTabBar} from '@/sections/MobileTabBar';
import {MobileTabBar} from '@site/sections/MobileTabBar';
/**
* 예약형(reservation) 껍데기 — 머리 · 본문 · 꼬리.
@@ -59,7 +59,6 @@ function useNavItems(): NavItem[] {
[
{id: 'intro', href: '#about', fallback: '소개'},
{id: spec.path, href: '#units', fallback: spec.label},
{id: 'pricing', href: '#pricing', fallback: '요금'},
{id: 'info', href: '#info', fallback: '이용 정보'},
{id: 'booking', href: '#booking', fallback: '예약 안내'},
{id: 'photos', href: '#gallery', fallback: '사진'},
+3 -3
View File
@@ -1,6 +1,6 @@
import {useSite} from '@/lib/site-context';
import {galleryImages} from '@/lib/derive';
import {primaryImage} from '@/seo/meta';
import {useSite} from '@site/lib/site-context';
import {galleryImages} from '@site/lib/derive';
import {primaryImage} from '@site/seo/meta';
/**
* 첫 화면 — **큰 사진 한 장이 아니라 사진 격자다.**
+2 -2
View File
@@ -1,5 +1,5 @@
import {useSite} from '@/lib/site-context';
import {sectionName, unitSpec, unitViews} from '@/lib/derive';
import {useSite} from '@site/lib/site-context';
import {sectionName, unitSpec, unitViews} from '@site/lib/derive';
import {SectionHead} from './SectionHead';
/**
+6 -6
View File
@@ -1,18 +1,18 @@
import type {ReactNode} from 'react';
import {useSite} from '@/lib/site-context';
import {useSite} from '@site/lib/site-context';
import {
bookingLabel,
bookingActionLabel,
bookingLinks,
channelLabel,
heroFacts,
isSectionEnabled,
lowestPrice,
unitSpec,
} from '@/lib/derive';
import {formatKoreanDate, isoDate} from '@/lib/format';
} from '@site/lib/derive';
import {formatKoreanDate, isoDate} from '@site/lib/format';
// ★ 배럴(@/sections)이 아니라 파일을 직접 가리킨다 — 배럴은 섹션 열여덟을 전부 끌고 오고,
// 그 안에 lib/ui 가 있어 이 폴더로 순환 참조가 돌아온다.
import {MobileTabBar} from '@/sections/MobileTabBar';
import {MobileTabBar} from '@site/sections/MobileTabBar';
/**
* 스튜디오형 껍데기 — **가로 메뉴 바가 없다.**
@@ -114,7 +114,7 @@ export function Shell({children}: {children: ReactNode}) {
className="tap mt-5 inline-flex w-full items-center justify-center px-4 text-[length:var(--fs-sm)] font-bold transition-opacity hover:opacity-90"
style={{backgroundColor: 'var(--color-brand)', color: 'var(--tpl-bg)'}}
>
{bookingLabel(booking)}로 예약
{bookingActionLabel(booking)}
</a>
)}