[feat] solution: 템플릿 정의를 templates.json 한 파일로 — 업종 없는 id · 레이아웃 basic/paper 정리
템플릿 정보가 빌더·렌더러·백엔드에 따로 적혀 어긋나 있었다 — 백엔드 기본값이 없는 id 를 가리켰고, 음식점 강조색 오타, 섹션 간격이 빌더와 서버에서 달랐다. - shared/src/data/templates.json: 템플릿 4개(simple·magazine·retro·paper)와 업종별 허용·기본 - shared/lib/catalog.ts · backend/common/template_catalog.py: 같은 JSON 을 읽는다, 모르는 id 는 에러 - 저장·미리보기·발행에서 모르는 id 를 거절한다(site_service · site.py 422 · build_service 실패) - site: 레이아웃 등록표(basic·paper) + LayoutProvider, Shell→Frame, HomePage→SectionList - 연결 안 된 레이아웃 5개, 배치 고르기(variant), 서체 선택, 빌더 canvas/DevShowcase 삭제 - 빌더: 템플릿을 바꾸면 이전 템플릿이 켠 섹션을 끄고 안내 문구를 띄운다 - postgres-init/migrations/0023: stay-retro → retro, 병원 허용 밖은 NULL(운영 미적용) - Dockerfile·worker: 백엔드 이미지에 shared/src/data 복사 - docs: TEMPLATES.md 신설(세 폴더 역할·템플릿 추가·렌더링 순서), DATA_MODEL·ARCHITECTURE 등 갱신 shared·site·frontend tsc 통과, site vitest 통과, 백엔드 DB 없는 테스트 41 passed(DB 테스트 미실행) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
46b74b310b
commit
c6908629f3
183 files changed
+1824
-15243
No files matched your search
@@ -0,0 +1,230 @@
|
||||
import {useEffect, useState, type ReactNode} from 'react';
|
||||
import {Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {enabledSections} from '@site/lib/derive';
|
||||
import {isoDate} from '@site/lib/format';
|
||||
import {MobileTabBar} from '@site/sections/MobileTabBar';
|
||||
import {SongPlayer} from '@site/sections/SongPlayer';
|
||||
|
||||
interface TabEntry {
|
||||
label: string;
|
||||
anchor: string;
|
||||
}
|
||||
|
||||
const ANCHOR: Record<string, string> = {
|
||||
intro: 'about',
|
||||
info: 'info',
|
||||
rooms: 'units',
|
||||
menu: 'units',
|
||||
programs: 'units',
|
||||
pricing: 'pricing',
|
||||
booking: 'booking',
|
||||
space: 'space',
|
||||
inquiry: 'inquiry',
|
||||
exhibition: 'exhibition',
|
||||
photos: 'gallery',
|
||||
local: 'guide',
|
||||
weather: 'weather',
|
||||
map: 'location',
|
||||
faq: 'faq',
|
||||
songs: 'songs',
|
||||
daily: 'daily',
|
||||
chronicle: 'chronicle',
|
||||
reading: 'reading',
|
||||
people: 'people',
|
||||
quiz: 'quiz',
|
||||
postcard: 'postcard',
|
||||
video: 'video',
|
||||
itinerary: 'itinerary',
|
||||
};
|
||||
|
||||
const FALLBACK_LABEL: Record<string, string> = {
|
||||
about: '소개',
|
||||
info: '이용 정보',
|
||||
units: '객실',
|
||||
pricing: '요금',
|
||||
booking: '예약 안내',
|
||||
space: '공간',
|
||||
inquiry: '문의',
|
||||
exhibition: '관람 안내',
|
||||
gallery: '사진',
|
||||
guide: '주변',
|
||||
weather: '날씨',
|
||||
location: '오시는 길',
|
||||
faq: '자주 묻는 질문',
|
||||
songs: '노래',
|
||||
daily: '일력',
|
||||
chronicle: '연표',
|
||||
reading: '읽기',
|
||||
people: '인물',
|
||||
quiz: '퀴즈',
|
||||
postcard: '엽서',
|
||||
video: '영상',
|
||||
itinerary: '일정',
|
||||
};
|
||||
|
||||
function useTabEntries(): TabEntry[] {
|
||||
const payload = useSite();
|
||||
const seen = new Set<string>();
|
||||
const entries: TabEntry[] = [];
|
||||
|
||||
for (const section of enabledSections(payload)) {
|
||||
const anchor = ANCHOR[section.id];
|
||||
if (!anchor || seen.has(anchor)) continue;
|
||||
if (anchor === 'units' && payload.units.length === 0) continue;
|
||||
seen.add(anchor);
|
||||
entries.push({label: section.name?.trim() || FALLBACK_LABEL[anchor] || anchor, anchor});
|
||||
}
|
||||
|
||||
if (!seen.has('location')) entries.push({label: '오시는 길', anchor: 'location'});
|
||||
return entries;
|
||||
}
|
||||
|
||||
function useActiveAnchor(entries: TabEntry[]): string {
|
||||
const anchors = entries.map((entry) => entry.anchor).join(',');
|
||||
const [active, setActive] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof IntersectionObserver === 'undefined') return;
|
||||
const targets = anchors
|
||||
.split(',')
|
||||
.map((id) => document.getElementById(id))
|
||||
.filter((el): el is HTMLElement => el !== null);
|
||||
if (targets.length === 0) return;
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(records) => {
|
||||
const hit = records.find((record) => record.isIntersecting);
|
||||
if (hit) setActive(hit.target.id);
|
||||
},
|
||||
{rootMargin: '-45% 0px -50% 0px'},
|
||||
);
|
||||
targets.forEach((el) => observer.observe(el));
|
||||
return () => observer.disconnect();
|
||||
}, [anchors]);
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
export function Frame({children}: {children: ReactNode}) {
|
||||
const payload = useSite();
|
||||
const {place, site} = payload;
|
||||
const entries = useTabEntries();
|
||||
const active = useActiveAnchor(entries);
|
||||
const address = place.roadAddress ?? place.address;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex min-h-screen w-full flex-col"
|
||||
style={{backgroundColor: 'var(--tpl-bg, #fff)', color: 'var(--tpl-text, #1a1a1a)'}}
|
||||
>
|
||||
<header
|
||||
className="border-line safe-t sticky top-0 z-40 w-full border-b backdrop-blur-md"
|
||||
style={{backgroundColor: 'color-mix(in srgb, var(--tpl-surface, #fff) 90%, transparent)'}}
|
||||
>
|
||||
<div className="shell flex h-14 items-center justify-between gap-3">
|
||||
<a
|
||||
href="#top"
|
||||
className="serif min-w-0 truncate text-[length:var(--fs-lead)]"
|
||||
style={{fontWeight: 'var(--tpl-heading-weight, 400)'}}
|
||||
>
|
||||
{place.name}
|
||||
</a>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<SongPlayer />
|
||||
{place.phone && (
|
||||
<a
|
||||
href={`tel:${place.phone}`}
|
||||
className="tap flex size-9 items-center justify-center rounded-full"
|
||||
aria-label="전화 걸기"
|
||||
>
|
||||
<Phone className="size-4" />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{entries.length > 0 && (
|
||||
<nav aria-label="주요 메뉴" className="border-line border-t">
|
||||
<ul className="shell flex gap-5 overflow-x-auto">
|
||||
{entries.map((entry) => {
|
||||
const on = entry.anchor === active;
|
||||
return (
|
||||
<li key={entry.anchor} className="shrink-0">
|
||||
<a
|
||||
href={`#${entry.anchor}`}
|
||||
aria-current={on ? 'true' : undefined}
|
||||
className="tap flex h-11 items-center whitespace-nowrap text-[length:var(--fs-sm)]"
|
||||
style={{
|
||||
fontWeight: on ? 700 : 400,
|
||||
boxShadow: on ? 'inset 0 -2px 0 currentColor' : undefined,
|
||||
}}
|
||||
>
|
||||
{entry.label}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</nav>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div className="flex w-full flex-1 flex-col">{children}</div>
|
||||
|
||||
<footer
|
||||
className="w-full pb-28 pt-12 md:pb-14"
|
||||
style={{backgroundColor: 'var(--tpl-surface-alt, #f5f5f4)'}}
|
||||
>
|
||||
<div className="shell flex flex-col gap-4 text-[length:var(--fs-sm)]">
|
||||
<p className="serif" style={{fontSize: 'var(--fs-lead)', fontWeight: 'var(--tpl-heading-weight, 400)'}}>
|
||||
{place.name}
|
||||
</p>
|
||||
{address && <p className="opacity-100">{address}</p>}
|
||||
{place.phone && (
|
||||
<p>
|
||||
<a href={`tel:${place.phone}`} className="underline-offset-2 hover:underline">
|
||||
{place.phone}
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="border-line flex flex-wrap items-center gap-x-3 gap-y-1 border-t pt-4 text-[length:var(--fs-xs)] opacity-100">
|
||||
<span>상호: {place.name}</span>
|
||||
{place.legal?.representative && <span>대표: {place.legal.representative}</span>}
|
||||
{place.legal?.businessRegistrationNumber && (
|
||||
<span>사업자등록번호: {place.legal.businessRegistrationNumber}</span>
|
||||
)}
|
||||
{place.legal?.mailOrderNumber && <span>통신판매업신고: {place.legal.mailOrderNumber}</span>}
|
||||
{place.legal?.licenseNumber && (
|
||||
<span>
|
||||
{place.legal.licenseLabel ?? '인허가번호'}: {place.legal.licenseNumber}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<p className="byline text-[length:var(--fs-xs)] opacity-100">
|
||||
<span className="author">작성·운영 {place.name}</span>
|
||||
{' · 최종 업데이트: '}
|
||||
<time dateTime={site.updatedAt}>{isoDate(site.updatedAt)}</time>
|
||||
</p>
|
||||
|
||||
<p className="text-[length:var(--fs-xs)] opacity-100">
|
||||
<a
|
||||
href="https://www.o2osolution.ai/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="underline-offset-2 hover:underline"
|
||||
>
|
||||
AI O2O
|
||||
</a>
|
||||
의 Web4Ai로 만든 사이트입니다.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<MobileTabBar />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user