- 게이트: DISCLOSURE_TOP_MISSING, APPROVED_*, UNAPPROVED_IN_INDEXABLE_BUILD, PRESS_VOICE 규칙화, 픽스처 추가 (16/16) - 생성기: --site 옵션, 병원 확인 답변(clinicAnswers) 근거 [A] - default_briefs.mjs 첫 배치 자동 기획, workers/supporters-build/run.mjs - 랜딩: SAMPLE REPORT 라벨 "실제 사례"로 (haewon 지시) - v2 §11-6·§11-7 기록, E2E 리포트 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
88 lines
4.1 KiB
TypeScript
88 lines
4.1 KiB
TypeScript
// 데이터 진입점. 병원 사실(factSheet) · 사람(authors) · 매체(site) 세 파일만 읽고, 페이지는 이 모듈을 통해서만 값을 쓴다.
|
|
// 값이 비어 있으면(null·''·[]) 화면에는 PENDING("확인 대기")을 쓰고 스키마에서는 그 필드를 뺀다. 지어내지 않는다.
|
|
import fact from './data/factSheet.json';
|
|
import authors from './data/authors.json';
|
|
import site from './data/site.json';
|
|
|
|
export const PENDING = '확인 대기';
|
|
export const SITE_NAME = site.siteName || `${fact.shortName || '병원'} 서포터즈`;
|
|
export const SITE_TAGLINE = site.tagline || `${fact.shortName || '병원'}를 알아보는 사람들의 질문에 먼저 답하는 서포터즈 매체`;
|
|
export const INDEXABLE = import.meta.env.PUBLIC_INDEXABLE === 'true';
|
|
|
|
export const CATEGORY_LABELS: Record<string, string> = {
|
|
A: '병원 소개', B: '방문·예약', C: '선택 기준', D: '시술 정보', E: '안전·신뢰', F: '가격·이벤트', G: '후기·평판',
|
|
};
|
|
|
|
export { fact, authors, site };
|
|
|
|
/** 지원 관계 고지(글 첫 부분). site.sponsorNotice 가 비어 있으면 상단 고지를 렌더하지 않는다(v2 §12-2, haewon 승인 후 켠다). */
|
|
export const SPONSOR_NOTICE: string = (site as AnyRec).sponsorNotice || '';
|
|
/** 색인 허용 빌드에서는 개설자 게시 승인(approvedAt)이 있는 글만 낸다. 미리보기(noindex)는 전부. */
|
|
export const isPublishable = (p: { data: { approvedAt?: string } }): boolean => !INDEXABLE || has(p.data.approvedAt);
|
|
|
|
/** 비어 있으면 PENDING. 화면 표시용. */
|
|
export const v = (x: unknown, fallback: string = PENDING): string => (x === null || x === undefined || x === '' ? fallback : String(x));
|
|
/** 비어 있지 않은 값만. 스키마·링크용. */
|
|
export const has = (x: unknown): boolean => !(x === null || x === undefined || x === '' || (Array.isArray(x) && x.length === 0));
|
|
|
|
type AnyRec = Record<string, any>;
|
|
export const surfaces: AnyRec = (fact as AnyRec).surfaces ?? {};
|
|
export const surface = (key: string): AnyRec => surfaces[key] ?? {};
|
|
export const reservationUrl: string = (fact as AnyRec).reservationUrl || fact.url || '';
|
|
export const editor = (): AnyRec => supporter(site.editorId) ?? { name: PENDING, role: '편집 책임', email: '', bio: '' };
|
|
|
|
export function supporter(id: string) {
|
|
return (authors.supporters as Record<string, any>)[id];
|
|
}
|
|
export function physician(id: string) {
|
|
return (authors.physicians as Record<string, any>)[id];
|
|
}
|
|
|
|
const compact = (o: AnyRec): AnyRec => Object.fromEntries(Object.entries(o).filter(([, val]) => has(val)));
|
|
|
|
export function clinicSchema(siteUrl: string) {
|
|
const f = fact as AnyRec;
|
|
const sameAs = ['youtube', 'instagram', 'facebook', 'gangnamunni'].map((k) => surface(k).url).concat(f.urlEn).filter(has);
|
|
return compact({
|
|
'@type': ['MedicalClinic', 'Organization'],
|
|
'@id': `${f.url}/#clinic`,
|
|
name: f.name,
|
|
alternateName: f.shortName,
|
|
url: f.url,
|
|
telephone: f.phone,
|
|
faxNumber: f.fax,
|
|
foundingDate: f.founded,
|
|
address: has(f.address?.street) ? {
|
|
'@type': 'PostalAddress',
|
|
streetAddress: f.address.street,
|
|
addressLocality: f.address.locality,
|
|
addressRegion: f.address.region,
|
|
addressCountry: 'KR',
|
|
} : null,
|
|
openingHoursSpecification: (f.hours?.schema ?? []).map((h: AnyRec) => ({ '@type': 'OpeningHoursSpecification', ...h })),
|
|
medicalSpecialty: ['PlasticSurgery'],
|
|
sameAs,
|
|
image: has(site.buildingImage?.src) ? `${siteUrl}${site.buildingImage.src}` : null,
|
|
});
|
|
}
|
|
|
|
export function personSchema(id: string, siteUrl: string) {
|
|
const a = supporter(id);
|
|
return compact({ '@type': 'Person', '@id': `${siteUrl}/authors/${id}#person`, name: a.name, jobTitle: a.role, url: `${siteUrl}/authors/${id}`, sameAs: a.sameAs });
|
|
}
|
|
|
|
export function physicianSchema(id: string) {
|
|
const p = physician(id);
|
|
return compact({
|
|
'@type': 'Physician',
|
|
'@id': `${p.url}#physician`,
|
|
name: p.name,
|
|
jobTitle: p.title,
|
|
url: p.url,
|
|
sameAs: p.sameAs,
|
|
medicalSpecialty: 'PlasticSurgery',
|
|
worksFor: { '@id': `${fact.url}/#clinic` },
|
|
image: p.image ?? null,
|
|
});
|
|
}
|