feat(supporters): 템플릿화 — 병원 고유값을 데이터로 분리하고 templates/supporters-astro 내보내기

- src/data/site.json 신설(매체 이름·로고·홈 큐레이션), factSheet에 kind·areaLabel·transitShort·transitNote·reservationUrl·doctorsUrl·youtube.title 추가
- lib.ts: PENDING('확인 대기')·v()·has()·surface()·editor() 도입, 스키마는 빈 값을 빼고 생성
- 페이지·컴포넌트 15개에서 뷰성형외과 하드코딩 제거, 빈 데이터 empty-state (글 0편·영상 0건·뉴스 0건·이미지 없음)
- 검증: 28페이지 표시 텍스트·구조 지문 이전 빌드와 동일(홈 title 마침표 1건만 정정), JSON-LD 차이는 빈 sameAs 제거뿐
- scripts/export_template.mjs + scripts/template/data(빈 데이터 세트) → templates/supporters-astro (빈 데이터로 10페이지 0오류 빌드, 게이트 통과)
- 게이트 픽스처를 자체 authors로 분리해 템플릿에서도 테스트 통과, 구조 기준선의 글 상세 페이지는 사전순 첫 글로 동적 선택

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Fable 5.1 committed 2026-09-07 14:07:14 +09:00
1 parent 49c5e46f23
commit 622441e6aa
100 files changed
+6886 -174

No files matched your search

@@ -0,0 +1,94 @@
---
import { getCollection, render } from 'astro:content';
import Base from '../../layouts/Base.astro';
import Summary from '../../components/Summary.astro';
import VideoLite from '../../components/VideoLite.astro';
import RelatedVideos from '../../components/RelatedVideos.astro';
import Gallery from '../../components/Gallery.astro';
import Faq from '../../components/Faq.astro';
import ReviewBox from '../../components/ReviewBox.astro';
import Sources from '../../components/Sources.astro';
import History from '../../components/History.astro';
import Disclosure from '../../components/Disclosure.astro';
import FactBlock from '../../components/FactBlock.astro';
import { CATEGORY_LABELS, SITE_NAME, clinicSchema, personSchema, physicianSchema, physician, supporter, fact, surface } from '../../lib';
export async function getStaticPaths() {
const posts = await getCollection('posts');
return posts.map((post) => ({ params: { id: post.id }, props: { post } }));
}
const { post } = Astro.props;
const d = post.data;
const { Content } = await render(post);
const site = Astro.site!.toString().replace(/\/$/, '');
const url = `${site}/posts/${post.id}`;
const videos = d.videos.length ? d.videos : d.video ? [d.video] : [];
const [mainVideo, ...moreVideos] = videos;
const reviewer = d.reviewer ? physician(d.reviewer) : null;
const article: Record<string, any> = {
'@type': ['Article', 'MedicalWebPage'],
'@id': `${url}#article`,
headline: d.title,
description: d.description,
inLanguage: 'ko',
url,
mainEntityOfPage: url,
datePublished: d.datePublished,
dateModified: d.dateModified,
author: { '@id': `${site}/authors/${d.author}#person` },
publisher: { '@type': 'Organization', name: SITE_NAME, url: site },
about: { '@id': `${fact.url}/#clinic` },
image: [d.hero?.src, ...d.gallery.map((g) => g.src)].filter(Boolean).map((s) => `${site}${s}`),
};
if (!article.image.length && clinicSchema(site).image) article.image = [clinicSchema(site).image];
if (!article.image.length) delete article.image;
// 감수가 실제로 끝난 글에만 reviewedBy를 넣는다. 감수 예정 상태에서 넣으면 허위 표기다.
if (reviewer && d.reviewStatus === 'reviewed') { article.reviewedBy = { '@id': `${reviewer.url}#physician` }; if (d.reviewedAt) article.lastReviewed = d.reviewedAt; }
if (videos.length) article.video = videos.map((v) => ({ '@type': 'VideoObject', name: v.title, embedUrl: `https://www.youtube-nocookie.com/embed/${v.id}`, url: `https://www.youtube.com/watch?v=${v.id}`, thumbnailUrl: `https://i.ytimg.com/vi/${v.id}/hqdefault.jpg`, uploadDate: v.published ?? d.datePublished, description: v.title, publisher: { '@type': 'Organization', name: `${surface('youtube').title ?? fact.shortName} (YouTube)` } }));
const graph: any[] = [article, personSchema(d.author, site), clinicSchema(site)];
if (d.reviewer) graph.push(physicianSchema(d.reviewer));
if (d.faq.length) graph.push({ '@type': 'FAQPage', '@id': `${url}#faq`, mainEntity: d.faq.map((f) => ({ '@type': 'Question', name: f.q, acceptedAnswer: { '@type': 'Answer', text: f.a } })) });
---
<Base title={d.title} description={d.description} jsonLd={graph} type="article" ogImage={d.hero?.src}>
<article class="wrap" style="padding-bottom:4rem" data-qb={d.qbIds.join(',')}>
<header class="article-head">
<div class="eyebrow">{d.category} · {CATEGORY_LABELS[d.category]}</div>
<h1>{d.title}</h1>
<div class="meta">
<span>작성 {supporter(d.author).name}</span>
{reviewer && <span>{d.reviewStatus === 'reviewed' ? '의학 검토' : '설명'} {reviewer.name} {reviewer.title.split(' · ')[0]}{d.reviewStatus === 'reviewed' && d.reviewedAt ? ` (${d.reviewedAt})` : ''}</span>}
{d.reviewStatus !== 'reviewed' && <span>의학 검토 대기</span>}
<span>발행 {d.datePublished}</span>
<span>갱신 {d.dateModified}</span>
</div>
</header>
<Summary items={d.summary} />
{d.hero && (
<figure class="figure">
<img src={d.hero.src} alt={d.hero.alt} loading="eager" />
<figcaption>{d.hero.caption}</figcaption>
</figure>
)}
{mainVideo && <VideoLite {...mainVideo} />}
{reviewer && (
<div class="doctor-strip">
{reviewer.image && <img src={reviewer.image} alt={`${reviewer.name} ${reviewer.title}`} />}
<div>
<div class="name">{reviewer.name} <span style="font-weight:500;color:var(--slate-600)">{reviewer.title}</span></div>
<p class="creds">{reviewer.credentials.slice(0, 3).join(' · ')} <a href={reviewer.url} rel="noopener">프로필</a></p>
</div>
</div>
)}
<Content />
<Gallery items={d.gallery} />
<RelatedVideos items={moreVideos} title="이어서 볼 원장 영상" />
<Faq items={d.faq} />
<ReviewBox author={d.author} reviewer={d.reviewer} status={d.reviewStatus} dateModified={d.reviewedAt ?? d.dateModified} />
<Sources items={d.sources} />
<History items={d.history} />
<FactBlock compact />
<Disclosure />
</article>
</Base>
@@ -0,0 +1,41 @@
---
import { getCollection } from 'astro:content';
import Base from '../../layouts/Base.astro';
import PostCard from '../../components/PostCard.astro';
import { CATEGORY_LABELS, SITE_NAME, fact, v } from '../../lib';
const posts = (await getCollection('posts')).sort((a, b) => b.data.dateModified.localeCompare(a.data.dateModified));
const cats = Object.keys(CATEGORY_LABELS);
const site = Astro.site!.toString().replace(/\/$/, '');
const ld = { '@type': 'CollectionPage', '@id': `${site}/posts#page`, name: '전체 글', url: `${site}/posts`, inLanguage: 'ko', publisher: { '@type': 'Organization', name: SITE_NAME, url: site }, hasPart: posts.map((p) => ({ '@type': 'Article', headline: p.data.title, url: `${site}/posts/${p.id}`, dateModified: p.data.dateModified })) };
---
<Base title="전체 글" description={`${v(fact.shortName, '병원')}에 대해 자주 묻는 질문과 답을 주제별로 모았습니다.`} jsonLd={ld}>
<div class="wrap-wide" style="padding-bottom:4rem">
<header class="article-head"><div class="eyebrow">Archive</div><h1 class="serif">All Answers</h1><p style="color:var(--slate-600);margin-top:0.6rem">궁금한 주제를 골라 보세요. 글 하나가 질문 하나에 답합니다.</p></header>
{!posts.length && <p class="sub" style="color:var(--slate-500);margin-top:1.5rem">아직 발행한 글이 없습니다. 검토를 마친 글부터 차례로 올립니다.</p>}
<div class="cat-grid">
{cats.map((c) => {
const list = posts.filter((p) => p.data.category === c);
if (!list.length) return null;
return (<section id={`cat-${c}`} class={`cat span-${Math.min(list.length, 3)}`}><div class="section-title"><h2>{c}. {CATEGORY_LABELS[c]}</h2><span style="color:var(--slate-500);font-size:0.9rem">{list.length}편</span></div><div class="grid">{list.map((p) => <PostCard post={p} />)}</div></section>);
})}
</div>
</div>
</Base>
<style>
/* 카테고리 블록이 글 수만큼만 칸을 차지한다. 데스크톱 3열 → 태블릿 2열 → 모바일 1열 */
.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.4rem 1.25rem; margin-top: 2.4rem; align-items: start; }
.cat { scroll-margin-top: 90px; min-width: 0; }
.cat .section-title { margin-bottom: 1rem; }
.cat .grid { grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); }
.span-1 { grid-column: span 1; --cols: 1; }
.span-2 { grid-column: span 2; --cols: 2; }
.span-3 { grid-column: span 3; --cols: 3; }
@media (max-width: 1000px) {
.cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-3 { grid-column: span 2; --cols: 2; }
}
@media (max-width: 660px) {
.cat-grid { grid-template-columns: 1fr; gap: 2rem; }
.span-2, .span-3 { grid-column: span 1; --cols: 1; }
}
</style>