[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:
1 parent
387783b766
commit
b1386dd3ce
77 files changed
+710
-585
No files matched your search
@@ -3,8 +3,8 @@
|
||||
* ★ 붉은 점은 도시의 성격이 바뀐 해다. 점의 색이 장식이 아니라 정보라 범례를 함께 낸다.
|
||||
*/
|
||||
import type {ChronicleItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_ACCENT, ITEM_BORDER, ITEM_CARD, ItemSection, Rail, SourceLine} from './common';
|
||||
|
||||
export function ChronicleSection() {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
import {useEffect, useState} from 'react';
|
||||
import type {DailyItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_ACCENT, ITEM_BORDER, ITEM_CARD, ItemSection, SourceLine, tally} from './common';
|
||||
|
||||
export function DailySection() {
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
import {useCallback, useEffect, useState} from 'react';
|
||||
import {X} from 'lucide-react';
|
||||
import type {EventItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {
|
||||
ITEM_ACCENT,
|
||||
ITEM_BORDER,
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
import {useState} from 'react';
|
||||
import {planDay, type ItineraryItem, type PlannerStop} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_BORDER, ITEM_CARD, ITEM_INK, ITEM_INVERSE_INK, ItemSection, Rail, SourceLine, StopNo} from './common';
|
||||
import {RouteMap} from './RouteMap';
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* ★ 프레임 안은 사진이 있으면 사진, 없으면 활판 이니셜이다 — 빈 회색 상자를 두지 않는다.
|
||||
*/
|
||||
import type {PeopleItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_INVERSE, ItemSection, Rail, SourceLine, tally} from './common';
|
||||
|
||||
export function PeopleSection() {
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* 계절별 추천 하루 — 발행본.
|
||||
*
|
||||
* ★ 손님에게는 **지금 계절만** 보인다(간절기에는 두 계절). 12월에 온 손님에게
|
||||
* 봄·여름 코스까지 늘어놓으면 고를 것이 열두 개가 되고, 그건 추천이 아니라 목록이다.
|
||||
* ★ 그런데 HTML 에는 **전 계절을 굽는다.** 두 가지 이유다 —
|
||||
* ① 발행본은 정적이라 한 번 구우면 몇 달을 산다. 굽는 시점의 계절을 박으면 12월에도
|
||||
* 가을 코스가 걸린다. 그래서 계절 판정은 **브라우저에서** 한다(일력의 '오늘'과 같은 수법).
|
||||
* ② 이 사이트의 존재 이유가 인용이다. HTML 에서 지우면 검색·AI 가 나머지 계절을 못 읽는다.
|
||||
* → 안 맞는 계절은 `hidden` 으로 접어 둔다. 문서에는 있고 화면에는 없다.
|
||||
* ★ 시각은 화면이 계산한다(shared planDay) — 사장님은 머무는 시간만 적는다.
|
||||
* 조립 규칙이 빌더와 한 벌이라 사장님이 본 일정과 손님이 보는 일정이 같다.
|
||||
*/
|
||||
import {inSeason, planDay, plannerSeasons, plannerTop, type PlannerItem} from '@o2o/shared';
|
||||
import {useLiveSeasons} from '@/lib/use-live-seasons';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {ITEM_BORDER, ITEM_CARD, ITEM_INK, ITEM_INVERSE_INK, ItemSection, Rail, SourceLine, StopNo} from './common';
|
||||
import {RouteMap} from './RouteMap';
|
||||
|
||||
const RANK_LABEL = ['1위', '2위', '3위'];
|
||||
|
||||
/** 총 소요를 "7시간 10분"으로. 분만 쓰면 430분이 얼마인지 아무도 모른다. */
|
||||
function spanText(minutes: number): string {
|
||||
const hour = Math.floor(minutes / 60);
|
||||
const rest = minutes % 60;
|
||||
return [hour > 0 ? `${hour}시간` : '', rest > 0 ? `${rest}분` : ''].filter(Boolean).join(' ') || '0분';
|
||||
}
|
||||
|
||||
function PlanCard({item, rank}: {item: PlannerItem; rank: number}) {
|
||||
const day = planDay(item);
|
||||
|
||||
return (
|
||||
<article
|
||||
className="w4-paper w-[320px] shrink-0 snap-center border"
|
||||
style={{backgroundColor: ITEM_CARD, borderColor: ITEM_BORDER}}
|
||||
>
|
||||
<div
|
||||
className="flex items-center justify-between gap-2 border-b px-4 py-2.5"
|
||||
style={{borderColor: ITEM_BORDER}}
|
||||
>
|
||||
{/* ★ 1위만 채운다. 셋 다 채우면 순위가 안 읽히고, 채움색을 강조색으로 두면
|
||||
팔레트에 따라 글자가 안 보인다(연한 accent 위의 밝은 글자) — 글자색으로 채운다. */}
|
||||
<span
|
||||
className="border px-2 py-0.5 text-[11px] font-bold"
|
||||
style={
|
||||
rank === 0
|
||||
? {backgroundColor: ITEM_INK, color: ITEM_INVERSE_INK, borderColor: ITEM_INK}
|
||||
: {borderColor: ITEM_BORDER}
|
||||
}
|
||||
>
|
||||
{RANK_LABEL[rank] ?? `${rank + 1}위`}
|
||||
</span>
|
||||
<span className="text-[11px] opacity-60">
|
||||
{day.from}–{day.to} · {spanText(day.totalMinutes)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5 px-4 pt-3.5">
|
||||
<h4 className="serif text-lg font-bold">{item.name}</h4>
|
||||
{item.audience && <p className="text-[11px] opacity-60">{item.audience}</p>}
|
||||
{item.why && <p className="text-[13px] leading-relaxed opacity-80">{item.why}</p>}
|
||||
</div>
|
||||
|
||||
<RouteMap stops={day.stops.map((planned) => planned.stop)} />
|
||||
|
||||
<ol className="mt-3 px-4 pb-3">
|
||||
{day.stops.map((planned, index) => (
|
||||
<li key={`${planned.stop.name}-${index}`} className="grid grid-cols-[46px_minmax(0,1fr)] gap-2.5">
|
||||
{/* 시각 열 — 왼쪽에 붙어 정렬돼야 '시간표'로 읽힌다 */}
|
||||
<span className="serif pt-2 text-[12px] tabular-nums opacity-75">{planned.time}</span>
|
||||
<div className="border-l pb-2 pl-3" style={{borderColor: ITEM_BORDER}}>
|
||||
{planned.move > 0 && <p className="pt-1 text-[10px] opacity-50">↓ {planned.move}분 이동</p>}
|
||||
{/*
|
||||
★ 사진은 있을 때만. 없으면 빈 회색 상자 대신 지금처럼 활자만 선다 —
|
||||
이 팩의 규칙이다(주변 안내·인물 열전과 같다).
|
||||
★ 시간표의 리듬을 깨지 않게 작게. 사진이 커지면 '하루 계획'이 아니라 사진첩이 된다.
|
||||
*/}
|
||||
<div className="flex items-start gap-2.5 pt-1">
|
||||
{planned.stop.imageUrl && (
|
||||
<img
|
||||
src={planned.stop.imageUrl}
|
||||
alt={`${planned.stop.name} 사진`}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="size-12 shrink-0 object-cover"
|
||||
style={{border: `1px solid ${ITEM_BORDER}`}}
|
||||
/>
|
||||
)}
|
||||
<span className="min-w-0">
|
||||
<span className="block text-sm font-bold">
|
||||
<StopNo n={index + 1} />
|
||||
{planned.stop.name}
|
||||
</span>
|
||||
{planned.stop.note && (
|
||||
<span className="mt-0.5 block text-[12px] leading-relaxed opacity-75">
|
||||
{planned.stop.note}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-0.5 text-[10px] opacity-50">
|
||||
{planned.time}–{planned.until}
|
||||
{planned.stop.searchQuery && ` · 지도 검색 ${planned.stop.searchQuery}`}
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
|
||||
<div className="border-t border-dashed px-4 py-2.5" style={{borderColor: ITEM_BORDER}}>
|
||||
<SourceLine source={item.source} verified={item.verified} />
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
export function PlannerSection() {
|
||||
const payload = useSite();
|
||||
const parsed = sectionItems<PlannerItem>(payload, 'planner');
|
||||
|
||||
const now = useLiveSeasons();
|
||||
|
||||
if (parsed.items.length === 0) return null;
|
||||
|
||||
const seasons = plannerSeasons(parsed.items);
|
||||
// 계절을 안 적었으면 계절 묶음 없이 전체에서 top3 를 뽑는다 — 빈 소제목을 만들지 않는다.
|
||||
const groups = seasons.length > 0 ? seasons : [undefined];
|
||||
|
||||
// 지금 계절에 코스가 하나도 없으면(사장님이 그 계절을 안 채웠다) 접지 않고 전부 보여준다 —
|
||||
// 빈 섹션보다 철 지난 코스가 낫다.
|
||||
const shown = now.filter((season) => seasons.includes(season));
|
||||
const filtering = shown.length > 0;
|
||||
|
||||
return (
|
||||
<ItemSection
|
||||
id="planner"
|
||||
name={parsed.title || sectionName(payload, 'planner', '계절별 추천 하루')}
|
||||
subtitle={parsed.subtitle}
|
||||
count={
|
||||
filtering
|
||||
? `지금은 ${shown.join(' · ')} 코스입니다 · 시각은 출발 시각과 머무는 시간으로 계산한 것입니다`
|
||||
: '시각은 출발 시각과 머무는 시간으로 계산한 것입니다'
|
||||
}
|
||||
>
|
||||
<div className="space-y-10">
|
||||
{groups.map((season) => {
|
||||
const top = plannerTop(parsed.items, season);
|
||||
if (top.length === 0) return null;
|
||||
return (
|
||||
<div
|
||||
key={season ?? 'all'}
|
||||
className="space-y-3"
|
||||
// 문서에는 남기고 화면에서만 접는다 — 검색·AI 는 전 계절을 읽는다.
|
||||
hidden={filtering && !inSeason(season, shown)}
|
||||
>
|
||||
{season && <h3 className="serif text-lg font-bold">{season}</h3>}
|
||||
<Rail label={`${season ?? '추천'} 코스`}>
|
||||
{top.map((item, index) => (
|
||||
<PlanCard key={`${item.name}-${index}`} item={item} rank={index} />
|
||||
))}
|
||||
</Rail>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</ItemSection>
|
||||
);
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
* ([복사] 버튼은 두지 않는다 — 스크립트가 없어도 되는 화면을 스크립트로 만들 이유가 없다).
|
||||
*/
|
||||
import type {PostcardItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_ACCENT, ITEM_BORDER, ITEM_CARD, ITEM_INK, ItemSection, Rail, SourceLine, tally} from './common';
|
||||
|
||||
export function PostcardSection() {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
import {useState} from 'react';
|
||||
import type {QuizItem} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_ACCENT, ITEM_BORDER, ITEM_CARD, ITEM_INK, ItemSection, Rail, SourceLine} from './common';
|
||||
|
||||
export function QuizSection() {
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* ★ 타일은 회색으로 눕힌다. 읽어야 하는 건 지도가 아니라 **번호와 순서**다.
|
||||
*/
|
||||
import type {PlannerStop} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {naverDirectionsUrl, naverRouteUrl} from '@/lib/format';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {naverDirectionsUrl, naverRouteUrl} from '@site/lib/format';
|
||||
import {ITEM_ACCENT, ITEM_BORDER, ITEM_INVERSE_INK} from './common';
|
||||
|
||||
const TILE = 256;
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
import {useState} from 'react';
|
||||
import type {SongItem} from '@o2o/shared';
|
||||
import {Youtube} from 'lucide-react';
|
||||
import {youtubeSearchUrl} from '@/lib/format';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {youtubeSearchUrl} from '@site/lib/format';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {
|
||||
ITEM_ACCENT,
|
||||
ITEM_INVERSE,
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 그 제목이 다섯 덩이를 가르는 유일한 표지다.
|
||||
*/
|
||||
import {useState} from 'react';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {SongsSection} from './SongsSection';
|
||||
import {DailySection} from './DailySection';
|
||||
import {PeopleSection} from './PeopleSection';
|
||||
|
||||
@@ -33,8 +33,8 @@ import {
|
||||
youtubePoster,
|
||||
type VideoItem,
|
||||
} from '@o2o/shared';
|
||||
import {useSite} from '@/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@/lib/derive';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {ITEM_BORDER, ITEM_CARD, ItemSection, SourceLine} from './common';
|
||||
|
||||
export function VideoSection() {
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
*/
|
||||
import type {ReactNode} from 'react';
|
||||
import type {DataSource, DataVerified} from '@o2o/shared';
|
||||
import {Carousel} from '@/lib/ui';
|
||||
import {useLayout} from '@/lib/layout';
|
||||
import {Carousel} from '@site/lib/ui';
|
||||
import {useLayout} from '@site/lib/layout';
|
||||
// 안별 제목은 `lib/ui/Section` 과 **같은 파일**을 직접 가리킨다.
|
||||
// `@/sections` 배럴로 돌아가면 이 파일이 그 배럴 안에 있어 순환이다.
|
||||
import {SectionHead as ReservationHead} from '@/layouts/reservation/SectionHead';
|
||||
import {SectionHead as OasiHead} from '@/layouts/oasi/SectionHead';
|
||||
import {SectionHead as StudioHead} from '@/layouts/studio/SectionHead';
|
||||
import {SectionHead as PastelHead} from '@/layouts/pastel/SectionHead';
|
||||
import {SectionHead as EditorialHead} from '@/layouts/editorial/SectionHead';
|
||||
import {SectionHead as ReservationHead} from '@site/layouts/reservation/SectionHead';
|
||||
import {SectionHead as OasiHead} from '@site/layouts/oasi/SectionHead';
|
||||
import {SectionHead as StudioHead} from '@site/layouts/studio/SectionHead';
|
||||
import {SectionHead as PastelHead} from '@site/layouts/pastel/SectionHead';
|
||||
import {SectionHead as EditorialHead} from '@site/layouts/editorial/SectionHead';
|
||||
import './items.css';
|
||||
|
||||
/** 카드·종이 면. 섹션 바탕보다 한 단계 앞이다. */
|
||||
|
||||
@@ -11,7 +11,6 @@ import {ChronicleSection} from './ChronicleSection';
|
||||
import {PostcardSection} from './PostcardSection';
|
||||
import {QuizSection} from './QuizSection';
|
||||
import {ItinerarySection} from './ItinerarySection';
|
||||
import {PlannerSection} from './PlannerSection';
|
||||
import {VideoSection} from './VideoSection';
|
||||
import {StorySection} from './StorySection';
|
||||
import {EventSection} from './EventSection';
|
||||
@@ -24,8 +23,6 @@ export const ITEM_SECTIONS: Record<string, () => React.ReactElement | null> = {
|
||||
postcard: PostcardSection,
|
||||
quiz: QuizSection,
|
||||
itinerary: ItinerarySection,
|
||||
// ★ 계절별 추천 하루. 여행일정 개편 때 표에서 빠져 화면에서 사라졌었다 — 되살린다.
|
||||
planner: PlannerSection,
|
||||
video: VideoSection,
|
||||
// 인스타에 올라오는 그때그때의 행사. 사장님이 옮겨 적고 원문 주소를 단다.
|
||||
event: EventSection,
|
||||
|
||||
Reference in new issue
Block a user