{{title}}
+{{subtitle}}
+{{price_text}}
+ {{sold_html}} +diff --git a/assets/css/site.css b/assets/css/site.css new file mode 100644 index 0000000..81e1021 --- /dev/null +++ b/assets/css/site.css @@ -0,0 +1,1235 @@ +/* 한땀 — 사이트 스타일 전부 */ + +:root { + --paper: #F6F2EA; + --ink: #26241F; + --muted: #6B6357; + --sage: #6C7A63; + --clay: #A2705A; + --line: #DCD3C4; + + --serif: "Noto Serif KR", "AppleMyungjo", "Nanum Myeongjo", "Times New Roman", serif; + --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif; +} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + scroll-behavior: smooth; + word-break: keep-all; + overflow-wrap: break-word; + -webkit-text-size-adjust: 100%; +} + +body { + margin: 0; + background: var(--paper); + color: var(--ink); + font-family: var(--sans); + font-size: 17px; + font-weight: 400; + line-height: 1.75; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; +} + +h1, +h2, +h3 { + margin: 0; + font-family: var(--serif); + font-weight: 400; + letter-spacing: -0.02em; + line-height: 1.12; +} + +p { + margin: 0; +} + +a { + color: inherit; + text-decoration-thickness: 1px; + text-underline-offset: 0.18em; +} + +a:hover { + text-decoration-color: var(--sage); +} + +img { + display: block; + max-width: 100%; + height: auto; +} + +figure { + margin: 0; +} + +ul, +ol { + margin: 0; + padding: 0; +} + +strong { + font-weight: 500; +} + +::selection { + background: var(--ink); + color: var(--paper); +} + +:focus-visible { + outline: 2px solid var(--clay); + outline-offset: 3px; +} + +.shell { + width: min(1180px, calc(100% - 80px)); + margin-inline: auto; +} + +.skip-link { + position: absolute; + top: -100px; + left: 20px; + z-index: 10; + padding: 10px 16px; + background: var(--ink); + color: var(--paper); + font-size: 13px; + text-decoration: none; +} + +.skip-link:focus { + top: 16px; +} + +.label { + display: flex; + align-items: center; + gap: 9px; + margin: 0; + color: var(--muted); + font-family: var(--sans); + font-size: 11px; + font-weight: 500; + letter-spacing: 0.18em; + line-height: 1.4; + text-transform: uppercase; +} + +.label::before { + content: ""; + flex: none; + width: 16px; + height: 1px; + background: var(--sage); +} + +.label-invert { + color: rgba(246, 242, 234, 0.7); +} + +.label-invert::before { + background: rgba(246, 242, 234, 0.55); +} + +/* ---------------------------------------------------------------- header */ + +.site-head { + border-bottom: 1px solid var(--line); +} + +.head-inner { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 24px; + padding-block: 22px; +} + +.wordmark { + display: inline-flex; + align-items: baseline; + gap: 10px; + text-decoration: none; +} + +.wordmark-ko { + font-family: var(--serif); + font-size: 22px; + letter-spacing: -0.02em; + line-height: 1; +} + +.wordmark-en { + color: var(--muted); + font-size: 9px; + font-weight: 500; + letter-spacing: 0.22em; + line-height: 1; +} + +.nav { + display: flex; + gap: 26px; + font-size: 13px; + letter-spacing: 0.02em; +} + +.nav a { + color: var(--muted); + text-decoration: none; +} + +.nav a:hover { + color: var(--ink); + text-decoration: underline; + text-underline-offset: 0.25em; +} + +/* ------------------------------------------------------------------ hero */ + +.hero { + padding-block: clamp(44px, 6vw, 88px) clamp(80px, 10vw, 140px); +} + +.hero-grid { + display: grid; + grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); + gap: clamp(36px, 6vw, 96px); + align-items: end; +} + +.hero-copy { + padding-bottom: clamp(0px, 4vw, 56px); +} + +.hero h1 { + font-size: clamp(3rem, 6vw, 5.75rem); + letter-spacing: -0.035em; + line-height: 0.98; + animation: rise 0.9s cubic-bezier(0.2, 0.6, 0.2, 1) both; +} + +.hero-lede { + max-width: 36ch; + margin-top: 28px; + font-size: 17px; + line-height: 1.8; + animation: rise 0.9s 0.08s cubic-bezier(0.2, 0.6, 0.2, 1) both; +} + +.hero-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 24px; + margin-top: 32px; + animation: rise 0.9s 0.16s cubic-bezier(0.2, 0.6, 0.2, 1) both; +} + +.hero-meta { + margin-top: 28px; + color: var(--muted); + font-size: 12px; + letter-spacing: 0.04em; + animation: rise 0.9s 0.24s cubic-bezier(0.2, 0.6, 0.2, 1) both; +} + +.hero-media { + aspect-ratio: 4 / 5; + overflow: hidden; + background: var(--line); +} + +.hero-media img { + width: 100%; + height: 110%; + object-fit: cover; + object-position: center top; + animation: settle 1.4s cubic-bezier(0.2, 0.6, 0.2, 1) both; +} + +.hero-figure figcaption { + display: flex; + justify-content: space-between; + gap: 16px; + margin-top: 12px; + color: var(--muted); + font-size: 12px; + line-height: 1.6; +} + +.hero-figure figcaption a { + color: var(--ink); + text-decoration: none; +} + +.hero-figure figcaption a:hover { + border-bottom: 1px solid var(--sage); +} + +/* ---------------------------------------------------------------- buttons */ + +.btn { + display: inline-block; + appearance: none; + padding: 14px 22px; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--ink); + color: var(--paper); + font-family: var(--sans); + font-size: 13px; + font-weight: 500; + letter-spacing: 0.03em; + line-height: 1.4; + text-align: center; + text-decoration: none; + cursor: pointer; + transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; +} + +.btn:hover { + background: transparent; + color: var(--ink); +} + +.btn:disabled, +.btn-disabled { + border-style: dashed; + border-color: var(--muted); + background: transparent; + color: var(--muted); + cursor: not-allowed; +} + +.btn:disabled:hover, +.btn-disabled:hover { + border-color: var(--muted); + background: transparent; + color: var(--muted); +} + +.text-link { + border-bottom: 1px solid var(--ink); + padding-bottom: 2px; + font-size: 13px; + text-decoration: none; + transition: color 0.2s ease, border-color 0.2s ease; +} + +.text-link:hover { + border-color: var(--sage); +} + +.pending { + max-width: 280px; + margin-top: 24px; + padding-top: 12px; + border-top: 1px solid var(--line); + color: var(--muted); + font-size: 12px; + letter-spacing: 0.02em; + line-height: 1.6; +} + +.pending-inline { + color: var(--muted); +} + +/* --------------------------------------------------------------- sections */ + +.section { + padding-block: clamp(72px, 9vw, 128px); + border-top: 1px solid var(--line); +} + +.section-head { + display: grid; + grid-template-columns: 120px minmax(0, 1fr) minmax(240px, 340px); + gap: clamp(20px, 4vw, 56px); + align-items: start; + margin-bottom: clamp(40px, 6vw, 72px); +} + +.section-head .label { + padding-top: 10px; +} + +.section-head h2 { + font-size: clamp(2.2rem, 4.4vw, 4rem); + letter-spacing: -0.035em; + line-height: 1.04; +} + +.section-note { + align-self: end; + justify-self: end; + max-width: 36ch; + color: var(--muted); + font-size: 14px; + line-height: 1.7; +} + +/* ----------------------------------------------------------------- works */ + +.works-grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: clamp(28px, 4vw, 52px); + align-items: start; +} + +.work-link { + display: block; + text-decoration: none; +} + +.work-figure { + aspect-ratio: 4 / 5; + overflow: hidden; + background: var(--line); +} + +.work-figure img { + width: 100%; + height: 100%; + object-fit: cover; + transition: transform 0.7s cubic-bezier(0.2, 0.6, 0.2, 1); +} + +.work-link:hover .work-figure img, +.work-link:focus-visible .work-figure img { + transform: scale(1.02); +} + +.work-caption { + padding-top: 16px; +} + +.work-caption h3 { + font-size: clamp(1.2rem, 1.7vw, 1.55rem); + line-height: 1.25; +} + +.work-link:hover h3 { + text-decoration: underline; + text-decoration-thickness: 1px; + text-underline-offset: 0.18em; +} + +.work-sub { + margin-top: 6px; + color: var(--muted); + font-size: 14px; + line-height: 1.6; +} + +.work-price { + margin-top: 10px; + font-size: 14px; + font-variant-numeric: tabular-nums; +} + +.work-sold { + margin-top: 8px; + color: var(--muted); + font-size: 12px; +} + +/* --------------------------------------------------------------- process */ + +.process-list { + list-style: none; +} + +.process-step { + display: grid; + grid-template-columns: 80px minmax(0, 4fr) minmax(0, 5fr); + grid-template-areas: "num copy fig"; + gap: clamp(24px, 4vw, 64px); + padding-block: clamp(40px, 5.5vw, 72px); + border-top: 1px solid var(--line); + align-items: start; +} + +.process-step:first-child { + border-top: 0; + padding-top: 0; +} + +.process-step:nth-child(even) { + grid-template-areas: "num fig copy"; +} + +.process-step.no-image { + grid-template-columns: 80px minmax(0, 1fr); + grid-template-areas: "num copy"; +} + +.step-number { + grid-area: num; + color: var(--clay); + font-family: var(--serif); + font-size: clamp(2rem, 3.4vw, 3.2rem); + font-variant-numeric: tabular-nums; + line-height: 0.9; +} + +.step-copy { + grid-area: copy; +} + +.step-copy h3 { + margin-bottom: 14px; + font-size: clamp(1.45rem, 2.4vw, 2rem); + line-height: 1.2; +} + +.step-copy p { + max-width: 38ch; + font-size: 16px; + line-height: 1.8; +} + +.no-image .step-copy p { + max-width: 60ch; +} + +.step-figure { + grid-area: fig; + aspect-ratio: 4 / 3; + overflow: hidden; + background: var(--line); +} + +.step-figure img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.process-step:first-child .step-figure img { + object-position: 28% 38%; + transform: scale(1.28); +} + +.process-step:nth-child(3) .step-figure { + width: 100%; + max-width: 420px; + aspect-ratio: 3 / 4; + justify-self: end; +} + +/* ------------------------------------------------------------------- kit */ + +.kit { + margin-top: clamp(56px, 7vw, 96px); + padding-block: clamp(72px, 9vw, 120px); + background: var(--ink); + color: var(--paper); +} + +.kit-grid { + display: grid; + grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); + gap: clamp(36px, 6vw, 100px); + align-items: center; +} + +.kit h2 { + max-width: 12ch; + margin-top: 14px; + color: var(--paper); + font-size: clamp(2.3rem, 4.6vw, 4rem); + letter-spacing: -0.035em; + line-height: 1.04; +} + +.kit-sub { + margin-top: 18px; + color: rgba(246, 242, 234, 0.72); + font-size: 17px; +} + +.kit-copy p { + max-width: 46ch; + margin-top: 18px; + color: rgba(246, 242, 234, 0.78); + font-size: 16px; + line-height: 1.8; +} + +.kit-note { + padding-top: 16px; + border-top: 1px solid rgba(246, 242, 234, 0.22); + color: rgba(246, 242, 234, 0.66) !important; + font-size: 13px !important; +} + +.kit-price { + color: var(--paper) !important; + font-size: 18px !important; + font-variant-numeric: tabular-nums; +} + +.kit .btn { + margin-top: 24px; + border-color: var(--paper); + background: var(--paper); + color: var(--ink); +} + +.kit .btn:hover { + background: transparent; + color: var(--paper); +} + +.kit .pending { + border-color: rgba(246, 242, 234, 0.28); + color: rgba(246, 242, 234, 0.72); +} + +.kit-more { + display: block; + width: fit-content; + margin-top: 20px; + border-bottom: 1px solid rgba(246, 242, 234, 0.4); + color: var(--paper); + font-size: 13px; + text-decoration: none; +} + +.kit-more:hover { + border-color: var(--paper); + color: var(--paper); +} + +.kit-figure { + aspect-ratio: 4 / 5; + overflow: hidden; + background: #1b1a17; +} + +.kit-figure img { + width: 100%; + height: 100%; + object-fit: cover; +} + +/* ----------------------------------------------------------------- order */ + +.order-grid { + display: grid; + grid-template-columns: 1fr 1fr; + gap: clamp(32px, 6vw, 96px); +} + +.order-col h3 { + margin-bottom: 10px; + font-size: clamp(1.4rem, 2vw, 1.8rem); +} + +.info-list { + list-style: none; +} + +.info-list li { + padding-block: 14px; + border-top: 1px solid var(--line); + font-size: 15px; + line-height: 1.7; +} + +.info-list li:last-child { + border-bottom: 1px solid var(--line); +} + +.order-note { + max-width: 52ch; + margin-top: 32px; + color: var(--muted); + font-size: 14px; +} + +.order-note a { + color: var(--ink); +} + +/* --------------------------------------------------------------- contact */ + +.contact { + padding-block: clamp(80px, 10vw, 140px); +} + +.contact h2 { + margin-top: 16px; + font-size: clamp(2rem, 4.2vw, 3.6rem); + letter-spacing: -0.035em; + line-height: 1.15; +} + +.contact-email { + display: inline-block; + margin-top: 36px; + padding-bottom: 5px; + border-bottom: 1px solid var(--ink); + font-family: var(--serif); + font-size: clamp(1.7rem, 3.6vw, 2.9rem); + line-height: 1.2; + text-decoration: none; +} + +.contact-email:hover { + border-color: var(--sage); +} + +.contact-sub { + margin-top: 24px; + color: var(--muted); + font-size: 14px; +} + +/* ---------------------------------------------------------------- footer */ + +.site-foot { + margin-top: clamp(40px, 6vw, 80px); + padding-block: 32px 24px; + border-top: 1px solid var(--line); +} + +.foot-meta { + display: grid; + grid-template-columns: 1fr auto; + gap: 16px 32px; + align-items: start; + color: var(--muted); + font-size: 12px; + line-height: 1.6; +} + +.foot-contact { + text-align: right; +} + +.foot-sep { + margin-inline: 8px; + color: var(--line); +} + +.foot-brand { + margin-block: clamp(48px, 8vw, 96px) 28px; + font-family: var(--serif); + font-size: clamp(7rem, 26vw, 19rem); + letter-spacing: -0.055em; + line-height: 0.8; +} + +.foot-credits { + display: grid; + grid-template-columns: 120px minmax(0, 1fr); + gap: 20px; + padding-top: 20px; + border-top: 1px solid var(--line); +} + +.credits-title { + color: var(--muted); + font-size: 11px; + letter-spacing: 0.08em; +} + +.credits { + display: grid; + gap: 6px; + list-style: none; + color: var(--muted); + font-size: 11px; + line-height: 1.6; +} + +.credits span { + color: var(--ink); +} + +.foot-copy { + margin-top: 32px; + color: var(--muted); + font-size: 11px; +} + +/* --------------------------------------------------------------- product */ + +.back-link { + display: inline-block; + margin-block: 8px 28px; + color: var(--muted); + font-size: 13px; + text-decoration: none; +} + +.back-link:hover { + color: var(--ink); +} + +.product { + padding-bottom: clamp(40px, 6vw, 80px); +} + +.product-top { + display: grid; + grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); + gap: clamp(36px, 5vw, 80px); + align-items: start; +} + +.product-media { + aspect-ratio: 4 / 5; + overflow: hidden; + background: var(--line); +} + +.product-media img { + width: 100%; + height: 110%; + object-fit: cover; + object-position: center top; +} + +.product-info { + position: sticky; + top: 32px; + padding-top: clamp(8px, 3vw, 40px); +} + +.product-info h1 { + font-size: clamp(2.3rem, 4.4vw, 4.1rem); + letter-spacing: -0.035em; + line-height: 1.06; +} + +.product-sub { + margin-top: 14px; + color: var(--muted); + font-size: 17px; +} + +.product-price { + margin-top: 26px; + font-size: 18px; + font-variant-numeric: tabular-nums; +} + +.product-info .btn, +.product-info .pending { + margin-top: 24px; +} + +.product-sold { + margin-top: 8px; + color: var(--muted); + font-size: 12px; +} + +.spec { + margin-top: 44px; + border-top: 1px solid var(--line); +} + +.spec div { + display: grid; + grid-template-columns: 76px minmax(0, 1fr); + gap: 16px; + padding-block: 12px; + border-bottom: 1px solid var(--line); +} + +.spec dt { + color: var(--muted); + font-size: 12px; + letter-spacing: 0.02em; +} + +.spec dd { + margin: 0; + font-size: 14px; + line-height: 1.6; +} + +.product-story { + display: grid; + grid-template-columns: 120px minmax(0, 1fr); + gap: clamp(20px, 4vw, 56px); + align-items: start; + margin-top: clamp(72px, 10vw, 140px); +} + +.product-story .label { + padding-top: 10px; +} + +.prose { + max-width: 64ch; +} + +.prose p { + margin-bottom: 1.4em; + font-size: 17px; + line-height: 1.85; +} + +.prose p:first-child { + font-size: clamp(1.25rem, 1.9vw, 1.5rem); + line-height: 1.7; +} + +.prose p:last-child { + margin-bottom: 0; +} + +.prose h2 { + margin: 2em 0 0.7em; + font-size: clamp(1.4rem, 2.2vw, 1.8rem); +} + +.prose ul { + margin-bottom: 1.4em; + padding-left: 1.2em; +} + +.prose li { + margin-bottom: 0.4em; +} + +.prose figure { + margin-block: 32px; +} + +.gallery { + grid-column: 2; + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 20px; + margin-top: 24px; +} + +.gallery-figure { + aspect-ratio: 4 / 5; + overflow: hidden; + background: var(--line); +} + +.gallery-figure img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.pager { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 24px; + margin-top: clamp(80px, 10vw, 140px); + padding-top: 20px; + border-top: 1px solid var(--line); +} + +.pager-link { + display: block; + text-decoration: none; +} + +.pager-next { + text-align: right; +} + +.pager-label { + display: block; + color: var(--muted); + font-size: 11px; + letter-spacing: 0.08em; +} + +.pager-title { + display: block; + margin-top: 6px; + font-family: var(--serif); + font-size: clamp(1.2rem, 1.8vw, 1.5rem); + line-height: 1.3; +} + +.pager-link:hover .pager-title { + text-decoration: underline; + text-underline-offset: 0.2em; +} + +/* ---------------------------------------------------------------- motion */ + +@keyframes rise { + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes settle { + from { + opacity: 0; + transform: scale(1.03); + } + to { + opacity: 1; + transform: scale(1); + } +} + +@media (prefers-reduced-motion: reduce) { + html { + scroll-behavior: auto; + } + + *, + *::before, + *::after { + animation-duration: 0.01ms !important; + animation-delay: 0ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } + + .hero-media img { + transform: none; + } + + .work-link:hover .work-figure img, + .work-link:focus-visible .work-figure img { + transform: none; + } +} + +/* ------------------------------------------------------------- responsive */ + +@media (max-width: 1040px) { + .section-head { + grid-template-columns: 90px minmax(0, 1fr); + } + + .section-note { + grid-column: 2; + justify-self: start; + max-width: 46ch; + } + + .works-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +@media (max-width: 900px) { + .shell { + width: calc(100% - 48px); + } + + .hero-grid { + grid-template-columns: minmax(0, 1fr); + } + + .hero-copy { + padding-bottom: 0; + } + + .hero h1 { + font-size: clamp(3rem, 9.6vw, 5.2rem); + } + + .hero-lede { + max-width: 42ch; + } + + .hero-figure { + margin-top: 40px; + } + + .kit-grid { + grid-template-columns: minmax(0, 1fr); + } + + .kit-figure { + margin-top: 8px; + } + + .order-grid { + grid-template-columns: minmax(0, 1fr); + gap: 48px; + } + + .product-top { + grid-template-columns: minmax(0, 1fr); + } + + .product-info { + position: static; + padding-top: 0; + } + + .product-info .spec { + margin-top: 36px; + } + + .product-story { + grid-template-columns: minmax(0, 1fr); + } + + .product-story .label { + padding-top: 0; + } + + .gallery { + grid-column: 1; + } + + .foot-meta { + grid-template-columns: minmax(0, 1fr); + } + + .foot-contact { + text-align: left; + } + + .foot-credits { + grid-template-columns: minmax(0, 1fr); + gap: 10px; + } +} + +@media (max-width: 720px) { + .shell { + width: calc(100% - 40px); + } + + .nav { + gap: 18px; + font-size: 12px; + } + + .wordmark-en { + display: none; + } + + .section-head { + grid-template-columns: minmax(0, 1fr); + gap: 12px; + } + + .section-head .label { + padding-top: 0; + } + + .section-note { + grid-column: 1; + justify-self: start; + max-width: 42ch; + } + + .works-grid { + grid-template-columns: minmax(0, 1fr); + gap: 40px; + } + + .process-step, + .process-step:nth-child(even), + .process-step.no-image { + grid-template-columns: 44px minmax(0, 1fr); + grid-template-areas: + "num copy" + "num fig"; + gap: 16px 20px; + padding-block: 40px; + } + + .process-step:first-child { + padding-top: 0; + } + + .step-number { + font-size: 2rem; + padding-top: 2px; + } + + .step-figure, + .process-step:nth-child(3) .step-figure { + width: 100%; + max-width: none; + aspect-ratio: 4 / 3; + margin-top: 8px; + justify-self: stretch; + } + + .kit { + margin-top: 48px; + } + + .contact h2 br { + display: none; + } + + .contact-email { + font-size: clamp(1.5rem, 7vw, 2rem); + } + + .gallery { + grid-template-columns: minmax(0, 1fr); + } + + .pager { + grid-template-columns: minmax(0, 1fr); + gap: 18px; + } + + .pager-next { + text-align: left; + padding-top: 18px; + border-top: 1px solid var(--line); + } + + .foot-brand { + font-size: clamp(5.5rem, 30vw, 9rem); + } +} + +@media (max-width: 420px) { + .head-inner { + gap: 12px; + } + + .nav { + gap: 14px; + } + + .wordmark-ko { + font-size: 20px; + } + + .hero-meta { + font-size: 11px; + } + + .spec div { + grid-template-columns: 64px minmax(0, 1fr); + gap: 12px; + } +} diff --git a/build.py b/build.py new file mode 100644 index 0000000..e5d21aa --- /dev/null +++ b/build.py @@ -0,0 +1,679 @@ +#!/usr/bin/env python3 +"""한땀 정적 사이트 빌드. + +content/ + templates/ + assets/ -> dist/ +표준 라이브러리만 쓴다. 템플릿은 {{key}} 치환과 목록 반복만 지원한다. +""" + +from __future__ import annotations + +import html +import json +import re +import shutil +import sys +from pathlib import Path +from typing import Any, Dict, Iterable, List, Optional, Tuple + +ROOT = Path(__file__).resolve().parent +CONTENT = ROOT / "content" +TEMPLATES = ROOT / "templates" +ASSETS = ROOT / "assets" +DIST = ROOT / "dist" +SITE_BASE = "https://home.lala.dedyn.io/teamat/" + +VAR_RE = re.compile(r"{{\s*(\w+)\s*}}") +LOOP_RE = re.compile(r"{{#(\w+)}}(.*?){{/\1}}", re.S) +BOLD_RE = re.compile(r"\*\*(.+?)\*\*") +IMAGE_LINE_RE = re.compile(r"^!\[(.*?)\]\((.+?)\)$") + + +def esc(value: Any) -> str: + return html.escape(str(value), quote=True) + + +def fail(message: str) -> None: + print(f"빌드 오류: {message}", file=sys.stderr) + raise SystemExit(1) + + +# ---------------------------------------------------------------- front matter + + +def parse_scalar(value: str) -> Any: + value = value.strip() + if value in ("true", "false"): + return value == "true" + if value in ("", '""', "''"): + return "" + if re.fullmatch(r"-?\d+", value): + return int(value) + if len(value) >= 2 and value[0] == value[-1] and value[0] in ("'", '"'): + return value[1:-1] + return value + + +def parse_markdown_file(path: Path) -> Tuple[Dict[str, Any], str]: + raw = path.read_text(encoding="utf-8") + if not raw.startswith("---"): + fail(f"{path} 파일이 --- 로 시작하지 않습니다.") + + parts = raw.split("---", 2) + if len(parts) != 3: + fail(f"{path} 파일의 front matter가 닫히지 않았습니다.") + + front, body = parts[1], parts[2].lstrip("\n") + data: Dict[str, Any] = {} + current_key: Optional[str] = None + + for line in front.splitlines(): + if not line.strip() or line.lstrip().startswith("#"): + continue + + stripped = line.strip() + if stripped.startswith("- ") and current_key: + if data.get(current_key) is None: + data[current_key] = [] + if not isinstance(data[current_key], list): + fail(f"{path} 의 {current_key} 는 목록이 아닙니다.") + data[current_key].append(parse_scalar(stripped[2:])) + continue + + if ":" not in line: + fail(f"{path} 의 front matter 줄을 읽을 수 없습니다: {line}") + + key, value = line.split(":", 1) + key = key.strip() + value = value.strip() + if value == "": + data[key] = None + current_key = key + else: + data[key] = parse_scalar(value) + current_key = None + + for key, value in list(data.items()): + if value is None: + data[key] = "" + + return data, body + + +# ------------------------------------------------------------------- markdown + + +def inline_markdown(text: str) -> str: + return BOLD_RE.sub(r"\1", esc(text)) + + +def markdown_to_html(text: str, img_prefix: str = "") -> str: + lines = text.replace("\r\n", "\n").split("\n") + out: List[str] = [] + paragraph: List[str] = [] + index = 0 + + def flush_paragraph() -> None: + if paragraph: + out.append("
" + inline_markdown(" ".join(paragraph)) + "
") + paragraph.clear() + + while index < len(lines): + line = lines[index].strip() + + if not line: + flush_paragraph() + index += 1 + continue + + if line.startswith("## "): + flush_paragraph() + out.append("판매 완료
' if product.get("sold_out") else "" + items.append( + { + "href": f"p/{product['slug']}.html", + "image": esc(image), + "alt": esc(product.get("image_alt") or product["title"]), + "width": str(width), + "height": str(height), + "title": esc(product["title"]), + "subtitle": esc(product.get("subtitle", "")), + "price_text": format_price(product.get("price")), + "sold_html": sold_html, + } + ) + return items + + +def process_loop_items(steps: List[Dict[str, Any]]) -> List[Dict[str, Any]]: + items: List[Dict[str, Any]] = [] + for step in steps: + image = str(step.get("image", "")) + if image: + image_html = figure_html( + image, + str(step.get("image_alt") or step["title"]), + "step-figure", + ) + step_class = "process-step has-image" + else: + image_html = "" + step_class = "process-step no-image" + items.append( + { + "step": str(step["step"]), + "title": esc(step["title"]), + "body_html": markdown_to_html(step["body"]), + "image_html": image_html, + "step_class": step_class, + } + ) + return items + + +def build_index( + site: Dict[str, Any], + products: List[Dict[str, Any]], + steps: List[Dict[str, Any]], + shared: Dict[str, Any], + brand: Dict[str, Any], +) -> str: + featured = next((p for p in products if p.get("featured")), products[0]) + hero_image = str(featured["image"]) + hero_width, hero_height = image_size(hero_image) + + kit = next((p for p in products if p["slug"] == "kit-first-stitch"), None) + if kit is None: + fail("content/products/kit-first-stitch.md 가 필요합니다.") + kit_image = str(kit["image"]) + kit_width, kit_height = image_size(kit_image) + kit_body_html = markdown_to_html(kit["body"]) + kit_excerpt = kit_body_html.split("", 1)[0] + "" if "" in kit_body_html else kit_body_html + + kit_url = str(site.get("shop", {}).get("kit_url", "")).strip() + if kit_url: + kit_action = f'네이버에서 키트 구매' + else: + kit_action = '네이버 스마트스토어 준비 중
' + + store_url = str(site.get("shop", {}).get("store_url", "")).strip() + if store_url: + store_note = ( + f'네이버 스마트스토어' + "에서 주문하실 수 있습니다." + ) + else: + store_note = "온라인 주문은 준비 중입니다. 작품과 키트 문의는 메일로 받습니다." + + intro = collapse(brand["intro"]) + title = f"{brand['name']} — {brand['tagline']}" + context: Dict[str, Any] = dict(shared) + context.update( + { + "title": esc(title), + "description": esc(intro), + "og_title": esc(title), + "og_description": esc(intro), + "og_image": esc(absolute_url(hero_image)), + "og_type": "website", + "body_class": "is-home", + "intro": esc(intro), + "hero_image": esc(hero_image), + "hero_alt": esc(featured.get("image_alt") or featured["title"]), + "hero_width": str(hero_width), + "hero_height": str(hero_height), + "hero_title": esc(featured["title"]), + "hero_material": esc(featured.get("material", "")), + "hero_href": f"p/{featured['slug']}.html", + "products": product_loop_items(products), + "process": process_loop_items(steps), + "process_intro": esc(site.get("process_intro", "")), + "kit_title": esc(kit["title"]), + "kit_subtitle": esc(kit.get("subtitle", "")), + "kit_excerpt": kit_excerpt, + "kit_note": esc(site.get("shop", {}).get("kit_note", "")), + "kit_price": format_price(kit.get("price")), + "kit_action": kit_action, + "kit_href": f"p/{kit['slug']}.html", + "kit_image": esc(kit_image), + "kit_alt": esc(kit.get("image_alt") or kit["title"]), + "kit_width": str(kit_width), + "kit_height": str(kit_height), + "shipping": [{"text": esc(item)} for item in site.get("shipping", [])], + "care": [{"text": esc(item)} for item in site.get("care", [])], + "store_note": store_note, + } + ) + + body = render((TEMPLATES / "index.html").read_text(encoding="utf-8"), context, "index.html") + context["content"] = body + return render((TEMPLATES / "base.html").read_text(encoding="utf-8"), context, "base.html") + + +def pager_html(product: Optional[Dict[str, Any]], label: str, css_class: str) -> str: + if product is None: + return "" + return ( + f'' + f'{esc(label)}' + f'{esc(product["title"])}' + "" + ) + + +def build_product_page( + product: Dict[str, Any], + products: List[Dict[str, Any]], + shared: Dict[str, Any], + brand: Dict[str, Any], + index: int, +) -> str: + image = str(product["image"]) + width, height = image_size(image) + + if product.get("sold_out"): + buy_html = '판매 완료
' + else: + naver_url = str(product.get("naver_url", "")).strip() + if naver_url: + buy_html = f'네이버 스토어에서 구매' + else: + buy_html = ( + '" + ) + + gallery = product.get("gallery") or [] + gallery_figures: List[str] = [] + for number, gallery_image in enumerate(gallery, start=1): + gallery_figures.append( + figure_html( + str(gallery_image), + f"{product['title']} 추가 이미지 {number}", + "gallery-figure", + prefix="../", + ) + ) + gallery_html = '판매 완료
' if product.get("sold_out") else "", + "buy_html": buy_html, + "material": esc(material) or "—", + "size": esc(product.get("size", "")) or "—", + "care": esc(product.get("care", "")) or "—", + "body_html": markdown_to_html(product["body"], img_prefix="../"), + "gallery_html": gallery_html, + "prev_html": pager_html(prev_product, "이전 작품", "pager-link pager-link-prev") or list_fallback, + "next_html": pager_html(next_product, "다음 작품", "pager-link pager-link-next") or list_fallback, + } + ) + + # {{title}} is used both by the page and byWORKS
+최근에 만든 순서로 놓았습니다. 한 점씩, 천과 실을 고른 뒤에 시작합니다.
+{{subtitle}}
+{{price_text}}
+ {{sold_html}} +PROCESS
+{{process_intro}}
+KIT
+{{kit_subtitle}}
+ {{kit_excerpt}} +{{kit_note}}
+{{kit_price}}
+ {{kit_action}} + 키트 자세히 보기 → +ORDER
+주문 전에 소재와 규격을 한 번 더 확인해 주세요.
+{{store_note}}
+CONTACT
+작품과 키트에 대한 질문은 메일로 받습니다. {{instagram_link}}
+{{subtitle}}
+{{price_text}}
+ {{sold_html}} + {{buy_html}} + +STORY
+