import {useSite} from '@site/lib/site-context';
import {heroFacts, sectionBody} from '@site/lib/derive';
function dotDate(iso: string): string {
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
return m ? `${m[1]}. ${m[2]}. ${m[3]}` : iso;
}
function Post({publishedAt, body}: {publishedAt: string; body: string}) {
return (
{body}
);
}
const HOME_MAX = 3;
const FULL_FIRST = 5;
function Blog({full}: {full?: boolean}) {
const payload = useSite();
const posts = [...(payload.posts ?? [])].sort((a, b) => b.publishedAt.localeCompare(a.publishedAt));
if (posts.length === 0) return null;
const shown = posts.slice(0, full ? FULL_FIRST : HOME_MAX);
const older = full ? posts.slice(FULL_FIRST) : [];
const more = !full && posts.length > HOME_MAX;
return (
JOURNAL
미니 블로그
사장님이 직접 남기는 소식입니다.
{shown.map((item) => (
))}
{more && (
이야기에서 지난 소식 더 보기
)}
{older.length > 0 && (
지난 소식 {older.length}개
{older.map((item) => (
))}
)}
);
}
export function Intro() {
const payload = useSite();
const {narrative, place} = payload;
const own = sectionBody(payload, 'intro');
const about = own.length > 0 ? own : narrative.about;
const facts = heroFacts(payload);
return (
<>
{about.length > 0 && (
ABOUT
{place.name} 소개
{narrative.summary && {narrative.summary}
}
{about[0]}
{about.length > 1 && (
더 읽기
{about.slice(1).map((paragraph, i) => (
{paragraph}
))}
)}
{facts.length > 0 && (
{facts.map((row) => (
{row.label}
{row.value}
))}
)}
)}
>
);
}