도메인별 스키마(company·place·fact·local·site·job)를 걷어내고 public 한 벌로 폈다.
스키마 한정자가 붙은 순간부터 ORM·raw SQL·테스트 픽스처가 각자 그 이름을 들고 다녀야 했다.
- 공용 콘텐츠를 한 테이블로 되돌린다. spots·region_stories 를 따로 파 놓고 보니
같은 성격이 세 곳으로 갈라져 있었다 — `area_contents` 가 처음부터 content_type 으로
종류를 가르는 설계였고 그걸 쓰면 됐다. 관계(거리·숨김)만 `place_area_refs` 로 남긴다.
- migrations/ + scripts/migrate.py: `init.sql` 은 **DB 를 처음 만들 때만** 돈다. 파일에
컬럼을 더해도 이미 데이터가 든 DB 에는 반영되지 않는다 — 실제로 TourAPI 가 주변 정보를
받아 와도 저장할 곳이 없어 축제·맛집이 0건이었고, 화면에는 "그냥 안 나오는 것" 으로만 보였다.
DECISIONS.md 가 예고한 그대로다("운영 DB 가 생기는 순간 다시 필요해진다").
Alembic 을 쓰지 않는 이유는 스키마 정의가 이미 두 곳(ORM·init.sql)이라 세 번째를
더하면 어긋날 자리가 하나 더 생기기 때문이다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
75 lines
3.4 KiB
TypeScript
75 lines
3.4 KiB
TypeScript
/**
|
|
* 오늘의 엽서 — 발행본. 우표 자리·소인·가운데 괘선이 있는 뒷면 한 장.
|
|
* ★ 손님이 자기 계정에 붙여넣는 것이 목적이라, 문장을 그대로 긁을 수 있게 평문으로 둔다
|
|
* ([복사] 버튼은 두지 않는다 — 스크립트가 없어도 되는 화면을 스크립트로 만들 이유가 없다).
|
|
*/
|
|
import type {PostcardItem} from '@o2o/shared';
|
|
import {useSite} from '@/lib/site-context';
|
|
import {sectionItems, sectionName} from '@/lib/derive';
|
|
import {ITEM_ACCENT, ITEM_BORDER, ITEM_CARD, ITEM_INK, ItemSection, Rail, SourceLine, tally} from './common';
|
|
|
|
export function PostcardSection() {
|
|
const payload = useSite();
|
|
const parsed = sectionItems<PostcardItem>(payload, 'postcard');
|
|
if (parsed.items.length === 0) return null;
|
|
|
|
return (
|
|
<ItemSection
|
|
id="postcard"
|
|
name={parsed.title || sectionName(payload, 'postcard', '오늘의 엽서')}
|
|
subtitle={parsed.subtitle}
|
|
count={tally(parsed.items.length, parsed.unverified, '장')}
|
|
>
|
|
<Rail label="엽서 목록">
|
|
{parsed.items.map((card, index) => (
|
|
<article
|
|
key={`${card.line}-${index}`}
|
|
className="w4-paper w-[304px] shrink-0 snap-center border p-4"
|
|
style={{backgroundColor: ITEM_CARD, borderColor: ITEM_INK}}
|
|
>
|
|
{/* 앞면. 사진이 있을 때만 얹는다 — 없으면 뒷면 한 장이던 지금 모양 그대로다. */}
|
|
{card.imageUrl && (
|
|
<img
|
|
src={card.imageUrl}
|
|
alt={`${card.place || card.postmark || '엽서'} 사진`}
|
|
loading="lazy"
|
|
decoding="async"
|
|
className="mb-3.5 block aspect-3/2 w-full border object-cover"
|
|
style={{borderColor: ITEM_BORDER}}
|
|
/>
|
|
)}
|
|
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-3">
|
|
{/* 가운데 괘선 — 엽서 뒷면을 반으로 가르는 그 선 */}
|
|
<div className="min-w-0 border-r pr-3" style={{borderColor: ITEM_BORDER}}>
|
|
<p className="serif text-[17px] leading-snug">“{card.line}”</p>
|
|
{card.hashtags && card.hashtags.length > 0 && (
|
|
<p className="mt-2 text-[11px] opacity-60">{card.hashtags.join(' ')}</p>
|
|
)}
|
|
</div>
|
|
<div className="flex w-[62px] flex-col items-center gap-3">
|
|
<span
|
|
className="grid h-[56px] w-[44px] place-items-center border border-dashed text-center text-[9px] leading-tight opacity-60"
|
|
style={{borderColor: ITEM_BORDER}}
|
|
>
|
|
郵票
|
|
<br />
|
|
10원
|
|
</span>
|
|
<span
|
|
className="serif grid size-[54px] -rotate-6 place-items-center rounded-full border-2 px-1 text-center text-[9px] leading-tight"
|
|
style={{borderColor: ITEM_ACCENT, color: ITEM_ACCENT}}
|
|
>
|
|
{card.postmark || card.place || '소인'}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div className="mt-3 border-t border-dashed pt-2.5" style={{borderColor: ITEM_BORDER}}>
|
|
<SourceLine source={card.source} verified={card.verified} />
|
|
</div>
|
|
</article>
|
|
))}
|
|
</Rail>
|
|
</ItemSection>
|
|
);
|
|
}
|