[feat] solution/shared,frontend,site,backend: 붙여넣기 아이템 여섯 추가 · 발행본까지 내보내고 템플릿 토큰을 따르게 한다
아이템 넷(가요·일력·승차권·스케줄)만 있었고, 그마저 **발행본에는 하나도 안 나갔다.** `SectionSetting` 계약에 data 가 없어 사장님이 채운 JSON 이 payload 경계에서 통째로 버려졌다 — 소개문 body 와 같은 사연이다. 빌더에서는 보이는데 발행하면 없는 섹션이었다. 그리고 아이템 전부가 갱지색·주(朱)잉크·간판체를 hex 로 박고 있어, 템플릿을 매거진으로 바꿔도 아이템 섹션만 레트로로 남았다. 발행본은 색만 템플릿을 따랐다(계약에 생김새가 없었다). - shared/section-data: 읽는 쪽 계약을 계약 패키지로 — 항목 타입 · parseSectionData. 같은 JSON 을 빌더와 발행본이 읽는다. 파서가 두 벌이면 슬러그 규칙처럼 조용히 어긋난다 - frontend/dataSpec: 아이템 6종 추가 — 인물 열전 · 시간의 골목 · 문학 서가 · 오늘의 엽서 · 뒤집어 보는 질문 · 계절별 추천 하루. [+ 섹션 추가] 목록은 dataSpec 에서 파생돼 손댈 곳이 없다 - shared/planDay: 계절별 추천 하루는 시각을 **계산한다**. schedule 과 축이 다르다 — 저쪽은 사장님이 시각을 적고 여기는 출발 시각·소요 분에서 시각을 만든다. 조립 규칙을 shared 에 둔 이유는 파서와 같다(빌더와 발행본이 같은 시각을 내야 한다). 21시를 넘기는 칸은 넣지 않고 뺐다고 화면에 밝힌다 — 숨기면 왜 없는지 사장님이 모른다 - shared/site-payload: SectionSetting.data · SiteTheme.look 추가. backend/site_payload 는 해석 없이 싣는다 — 모양을 검사하면 프론트가 필드를 늘린 날 조용히 떨어뜨린다 - site/sections/items: 발행본 아이템 10종. **인터랙션은 옮기지 않았다** — 캔버스의 턴테이블은 '지금 한 곡'만 펴는데 그러면 나머지 곡의 문장이 HTML 에 없다. 인용이 이 사이트의 존재 이유다 - site/prerender: 아이템 항목을 고유 콘텐츠로 계수. 안 세면 "곡을 여덟 개 채웠는데 0건으로 발행이 막힌다"가 된다(intro.body 와 같은 구멍). 백엔드 fake 도 같은 규칙으로 맞췄다 - 아이템 색·서체를 전부 --tpl-* 토큰으로. retro/common → items/common, RETRO_* → ITEM_*. 글자 단계는 stone-400/500/600 대신 불투명도로 만든다 — 팔레트가 바뀌어도 위계가 남는다 - site/seo/head: look 을 --tpl-* 로 심고, 웹폰트는 템플릿이 쓰는 것만 내려보낸다. 전부 항상 실으면 쓰지도 않는 서체가 모든 발행 사이트의 첫 렌더를 늦춘다 - shared/color: deriveSurfaces 를 계약 패키지로. 캔버스·쇼케이스·발행본이 같은 식을 써야 미리보기가 거짓말을 하지 않는다. 프론트 lib/color 는 재수출만 남겼다 밟은 함정: 강조색을 그대로 쓰면 팔레트에 따라 큰 날짜 숫자와 순위 배지가 사라진다(연한 accent + 밝은 바탕). color-mix(accent 70%, currentColor) 로 색조는 남기고 대비만 확보했다. '확인/확인필요' 배지는 디자인이 아니라 신호라 신호색을 지키되 둘레 글자색만 섞는다. tsc·eslint·vite build 통과(frontend·admin·site), site 테스트 17 passed. 실물 프리렌더(레트로 look + 아이템): 열 섹션과 본문 문장 전부 포함, --tpl-font-heading 'Gugi' · border-width 2px, family=Gugi&Gowun+Batang 링크, 계절 묶음·순위·계산된 시각(09:30 출발 → 09:45 도착 → 11:15 → 11:25) 확인. 고유 콘텐츠 12건 ok=true. 옛 payload(look 없음)로 다시 구워 예전과 동일하게 나오는 것까지 확인. 백엔드는 이 환경에 PostgreSQL 이 없어 pytest 를 못 돌렸다 — _theme·_sections 는 함수 단위로 확인.
This commit is contained in:
1 parent
5ef3e5a7de
commit
71c0c1f6ab
47 files changed
+3579
-572
No files matched your search
@@ -2,3 +2,5 @@ export * from './types';
|
||||
export * from './lib/cn';
|
||||
export * from './lib/slug';
|
||||
export * from './lib/facts';
|
||||
export * from './lib/section-data';
|
||||
export * from './lib/color';
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 색 계산 — 디자인 토큰에서 '면 단계'를 만들 때 쓴다.
|
||||
*
|
||||
* ★ 빌더 캔버스 · 쇼케이스 · **발행 사이트**가 같은 식을 써야 한다.
|
||||
* 미리보기에서 예쁜 조합이 발행 화면에서 달라지면 미리보기가 거짓말이 된다.
|
||||
* 그래서 프론트 lib 이 아니라 계약 패키지에 둔다.
|
||||
*/
|
||||
|
||||
function rgb(hex: string): [number, number, number] {
|
||||
const n = parseInt(hex.replace('#', ''), 16);
|
||||
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
|
||||
}
|
||||
|
||||
/** 두 색을 섞는다. ratio=0 이면 a, 1 이면 b. */
|
||||
export function mix(a: string, b: string, ratio: number): string {
|
||||
// hex 가 아닌 값(css 변수·색 이름)이 들어오면 계산이 무의미하다 — 원본을 그대로 돌려준다.
|
||||
if (!/^#[0-9a-fA-F]{6}$/.test(a) || !/^#[0-9a-fA-F]{6}$/.test(b)) return a;
|
||||
const [ar, ag, ab] = rgb(a);
|
||||
const [br, bg, bb] = rgb(b);
|
||||
const ch = (x: number, y: number) => Math.round(x + (y - x) * ratio);
|
||||
const hex = (n: number) => n.toString(16).padStart(2, '0');
|
||||
return `#${hex(ch(ar, br))}${hex(ch(ag, bg))}${hex(ch(ab, bb))}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 템플릿 색 6개 → 면 토큰 4개.
|
||||
*
|
||||
* 캔버스와 쇼케이스가 공유하는 유도 규칙이다. 섹션 기본(bg) · paper · tint 가
|
||||
* 서로 다른 밝기여야 경계선 없이도 섹션이 나뉜다.
|
||||
*/
|
||||
export function deriveSurfaces(colors: {bg: string; card: string; text: string; secondary: string}) {
|
||||
return {
|
||||
surface: mix(colors.bg, colors.text, 0.06),
|
||||
surfaceAlt: colors.card,
|
||||
inverse: '#1c1917',
|
||||
border: colors.secondary,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
/**
|
||||
* 붙여넣기 아이템의 **읽는 쪽 계약** — "이 섹션 타입의 JSON 은 어떤 모양인가".
|
||||
*
|
||||
* ★ 왜 shared 인가
|
||||
* 같은 JSON 을 두 렌더러가 읽는다 — 빌더 캔버스(solution/frontend)와 발행 사이트(solution/site).
|
||||
* 파서를 각자 두면 "빌더에서는 보이는데 발행하면 없다"가 조용히 생긴다(슬러그 규칙과 같은 함정).
|
||||
* 프롬프트·예시·라벨처럼 **쓰는 쪽**만 필요한 것은 빌더에 남는다(`canvas/dataSpec.ts`).
|
||||
*/
|
||||
|
||||
/** 사장님이 스스로 매긴 확신. 미검증 값이 화면·JSON-LD 로 새지 않게 하는 첫 관문이다. */
|
||||
export type DataVerified = '확인' | '확인필요';
|
||||
|
||||
export interface DataSource {
|
||||
name: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface SongItem {
|
||||
title: string;
|
||||
artist?: string;
|
||||
lyricist?: string;
|
||||
composer?: string;
|
||||
year?: number;
|
||||
label?: string;
|
||||
labelColor?: string;
|
||||
story?: string;
|
||||
connection?: string;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface DailyItem {
|
||||
monthDay: string;
|
||||
category?: string;
|
||||
title: string;
|
||||
body?: string;
|
||||
season?: string;
|
||||
tags?: string[];
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface CourseStop {
|
||||
order?: number;
|
||||
name: string;
|
||||
minutes?: number;
|
||||
note?: string;
|
||||
searchQuery?: string;
|
||||
}
|
||||
|
||||
export interface CourseItem {
|
||||
name: string;
|
||||
duration?: string;
|
||||
startsFrom?: string;
|
||||
stops?: CourseStop[];
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface ScheduleSlot {
|
||||
/** 24시간 표기 "09:30". 정렬·플립 시각 표시가 이 값을 그대로 쓴다. */
|
||||
time: string;
|
||||
title: string;
|
||||
place?: string;
|
||||
minutes?: number;
|
||||
note?: string;
|
||||
searchQuery?: string;
|
||||
}
|
||||
|
||||
export interface ScheduleItem {
|
||||
name: string;
|
||||
/** 누구를 위한 하루인가("혼자 온 손님" · "아이와 함께"). 고르는 기준이 된다. */
|
||||
audience?: string;
|
||||
season?: string;
|
||||
slots?: ScheduleSlot[];
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface PeopleItem {
|
||||
name: string;
|
||||
/** 호·예명. 본명 옆에 나란히 불리는 이름이 있으면 프레임 아래 각인으로 붙는다. */
|
||||
aka?: string;
|
||||
years?: string;
|
||||
role?: string;
|
||||
oneLine?: string;
|
||||
/**
|
||||
* 사진 검색어. ★ 이미지 URL 을 받지 않는다 — 초상권·저작권 확인은 사장님 몫이고,
|
||||
* 모델이 지어낸 주소를 링크하면 깨진 사진이 인물 얼굴 자리에 남는다(LocalPlace.searchQuery 와 같은 규약).
|
||||
*/
|
||||
imageQuery?: string;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface ChronicleItem {
|
||||
/** 연도가 없으면 레일 끝으로 밀린다 — 순서를 지어내지 않는다. */
|
||||
year?: number;
|
||||
title: string;
|
||||
summary?: string;
|
||||
place?: string;
|
||||
/** 도시의 성격을 바꾼 해. 레일의 붉은 점이 이 값이다 — 점의 색이 장식이 아니라 정보다. */
|
||||
turning?: boolean;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface LiteratureItem {
|
||||
workTitle: string;
|
||||
author?: string;
|
||||
/** "1937" · "1937–1938 연재" 처럼 원문 그대로. 숫자로 좁히면 연재물이 안 들어간다. */
|
||||
year?: string;
|
||||
genre?: string;
|
||||
spineColor?: string;
|
||||
background?: string;
|
||||
whyHere?: string;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface PostcardItem {
|
||||
line: string;
|
||||
hashtags?: string[];
|
||||
place?: string;
|
||||
/** 소인에 찍을 짧은 지명. 없으면 place 가 그 자리에 들어간다. */
|
||||
postmark?: string;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface QuizItem {
|
||||
question: string;
|
||||
/** ★ answer 는 없다. 이 데이터는 검증되지 않은 줄이 더 많아서, 정답을 단정하면 틀린 걸 단정한다. */
|
||||
hint?: string;
|
||||
topic?: string;
|
||||
level?: string;
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
export interface PlannerStop {
|
||||
name: string;
|
||||
/** 여기서 머무는 시간(분). 없으면 60분으로 본다 — 못 재면 시각을 계산할 수 없다. */
|
||||
minutes?: number;
|
||||
/** 앞 칸에서 여기까지 오는 시간(분). 첫 칸은 업소에서 나서는 시간이다. */
|
||||
moveMinutes?: number;
|
||||
note?: string;
|
||||
searchQuery?: string;
|
||||
}
|
||||
|
||||
export interface PlannerItem {
|
||||
name: string;
|
||||
/** '봄' · '여름' · '가을' · '겨울'. 화면의 계절 탭이 이 값에서 파생된다. */
|
||||
season?: string;
|
||||
/** 그 계절 안에서의 순위. 1·2·3 만 쓴다 — 4위부터는 아무도 안 고른다. */
|
||||
rank?: number;
|
||||
/** 하루가 시작하는 시각 "HH:MM". 여기서부터 이동·머무는 시간을 더해 칸마다 시각을 박는다. */
|
||||
startTime?: string;
|
||||
audience?: string;
|
||||
/** 왜 이 계절에 이 코스인가. 순위를 납득시키는 한 문장. */
|
||||
why?: string;
|
||||
stops?: PlannerStop[];
|
||||
verified?: DataVerified;
|
||||
source?: DataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 섹션 타입 → 없으면 그 줄을 통째로 버리는 키.
|
||||
*
|
||||
* ★ 이 표가 곧 "붙여넣기 아이템이 무엇무엇인가"의 목록이다. 여기 없는 타입의 data 는 파싱하지 않는다.
|
||||
* 빈 껍데기(제목 없는 줄)가 화면에 줄만 남기는 걸 막는 자리이기도 하다.
|
||||
*/
|
||||
export const SECTION_ITEM_REQUIRED_KEY: Record<string, string> = {
|
||||
songs: 'title',
|
||||
daily: 'title',
|
||||
course: 'name',
|
||||
schedule: 'name',
|
||||
people: 'name',
|
||||
chronicle: 'title',
|
||||
literature: 'workTitle',
|
||||
postcard: 'line',
|
||||
quiz: 'question',
|
||||
planner: 'name',
|
||||
};
|
||||
|
||||
export interface ParsedSectionData<T> {
|
||||
items: T[];
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
/** 사람에게 보여줄 실패 사유. 있으면 items 는 비어 있다. */
|
||||
error?: string;
|
||||
/** 붙여넣은 JSON 의 kind 가 이 섹션과 다르다 — 다른 아이템 것을 넣었다는 뜻. */
|
||||
kindMismatch?: string;
|
||||
/** verified 가 '확인' 이 아닌 항목 수. 화면에 각주로 뜬다. */
|
||||
unverified: number;
|
||||
/** source 가 붙은 항목 수. */
|
||||
sourced: number;
|
||||
}
|
||||
|
||||
const EMPTY: ParsedSectionData<never> = {items: [], unverified: 0, sourced: 0};
|
||||
|
||||
/**
|
||||
* JSON.parse 실패를 "몇 번째 줄"로 바꾼다.
|
||||
*
|
||||
* ★ V8 은 두 가지 모양으로 던진다 — `position N (line L column C)` 형과,
|
||||
* 위치 없이 깨진 조각만 인용하는 `Unexpected token 'X', ..."조각" is not valid JSON` 형이다.
|
||||
* 앞의 것만 보면 후자에서 위치를 통째로 잃는다(실제로 그랬다). 뒤의 것은 조각을 원문에서 되찾아 센다.
|
||||
*/
|
||||
function locate(raw: string, message: string): string {
|
||||
const where = (pos: number) => {
|
||||
const before = raw.slice(0, Math.max(0, pos));
|
||||
const line = before.split('\n').length;
|
||||
const col = pos - before.lastIndexOf('\n');
|
||||
return `${line}번째 줄 ${col}번째 글자`;
|
||||
};
|
||||
|
||||
const token = /Unexpected token '(.)'/.exec(message)?.[1];
|
||||
// 쉼표를 하나 더 찍은 경우가 압도적으로 많다 — 그 말을 먼저 해 준다.
|
||||
const hint =
|
||||
token === '}' || token === ']'
|
||||
? '닫는 괄호 바로 앞에 쉼표가 하나 더 있는지 보세요.'
|
||||
: '그 앞의 쉼표·따옴표·괄호를 확인해 주세요.';
|
||||
|
||||
const lineCol = /line (\d+) column (\d+)/.exec(message);
|
||||
if (lineCol) return `${lineCol[1]}번째 줄 ${lineCol[2]}번째 글자에서 JSON 이 끊깁니다. ${hint}`;
|
||||
|
||||
const at = /position (\d+)/.exec(message);
|
||||
if (at) return `${where(Number(at[1]))}에서 JSON 이 끊깁니다. ${hint}`;
|
||||
|
||||
// 위치 없이 조각만 인용하는 형 — 그 조각을 원문에서 되찾는다.
|
||||
const quoted = /\.\.\."([\s\S]*?)" is not valid JSON/.exec(message)?.[1];
|
||||
const found = quoted ? raw.indexOf(quoted) : -1;
|
||||
if (found >= 0) return `${where(found + quoted!.length)} 부근에서 JSON 이 끊깁니다. ${hint}`;
|
||||
|
||||
return 'JSON 이 아닙니다. ChatGPT 가 준 답에서 { 로 시작해 } 로 끝나는 부분만 붙여넣어 주세요.';
|
||||
}
|
||||
|
||||
/**
|
||||
* 붙여넣은 문자열 → 렌더 가능한 항목.
|
||||
*
|
||||
* ★ 절대 throw 하지 않는다. 편집 중인 JSON 은 늘 깨져 있고, 깨진 순간 캔버스가 죽으면 못 고친다.
|
||||
* 발행 사이트에서도 같다 — 프리렌더가 예외로 죽으면 사이트 전체가 안 구워진다.
|
||||
*/
|
||||
export function parseSectionData<T extends object>(
|
||||
sectionType: string,
|
||||
raw: string | undefined,
|
||||
): ParsedSectionData<T> {
|
||||
const requiredKey = SECTION_ITEM_REQUIRED_KEY[sectionType];
|
||||
const text = (raw ?? '').trim();
|
||||
if (!requiredKey || !text) return EMPTY as ParsedSectionData<T>;
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(text);
|
||||
} catch (error) {
|
||||
return {...EMPTY, error: locate(text, error instanceof Error ? error.message : '')};
|
||||
}
|
||||
|
||||
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
||||
return {...EMPTY, error: '바깥이 { } 로 감싸인 JSON 이어야 합니다.'};
|
||||
}
|
||||
|
||||
const envelope = parsed as Record<string, unknown>;
|
||||
const kind = typeof envelope.kind === 'string' ? envelope.kind : undefined;
|
||||
const rawItems = envelope.items;
|
||||
if (!Array.isArray(rawItems)) {
|
||||
return {...EMPTY, error: 'items 배열이 없습니다. 프롬프트로 다시 만들어 주세요.'};
|
||||
}
|
||||
|
||||
const items = rawItems.filter(
|
||||
(item): item is T =>
|
||||
typeof item === 'object' &&
|
||||
item !== null &&
|
||||
!Array.isArray(item) &&
|
||||
typeof (item as Record<string, unknown>)[requiredKey] === 'string' &&
|
||||
((item as Record<string, unknown>)[requiredKey] as string).trim().length > 0,
|
||||
);
|
||||
|
||||
let unverified = 0;
|
||||
let sourced = 0;
|
||||
for (const item of items) {
|
||||
const row = item as Record<string, unknown>;
|
||||
if (row.verified !== '확인') unverified += 1;
|
||||
if (row.source && typeof row.source === 'object') sourced += 1;
|
||||
}
|
||||
|
||||
return {
|
||||
items,
|
||||
title: typeof envelope.title === 'string' ? envelope.title : undefined,
|
||||
subtitle: typeof envelope.subtitle === 'string' ? envelope.subtitle : undefined,
|
||||
kindMismatch: kind && kind !== sectionType ? kind : undefined,
|
||||
unverified,
|
||||
sourced,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* ─────────────────────────────────────────────────────────────
|
||||
* 계절별 추천 하루 — 시각을 **계산해서** 짜 준다.
|
||||
*
|
||||
* ★ 왜 shared 인가: 파서와 같은 이유다. 빌더 캔버스와 발행 사이트가 같은 코스에서 **같은 시각**을
|
||||
* 내놓아야 한다. 조립 규칙이 두 벌이면 사장님이 본 일정과 손님이 보는 일정이 조용히 갈린다.
|
||||
* ★ 여행 스케줄(schedule)과 축이 다르다 — 저쪽은 사장님이 시각을 적고, 여기는 시각을 계산한다.
|
||||
* 그래서 사장님은 "몇 분 걸리나"만 알면 되고, 출발 시각을 바꾸면 하루가 통째로 밀린다.
|
||||
* ───────────────────────────────────────────────────────────── */
|
||||
|
||||
/** 밤 9시를 넘기는 칸은 넣지 않는다 — 짜 준 일정이 손님을 밤까지 끌고 다니면 그 순간 신뢰를 잃는다. */
|
||||
const PLAN_ENDS_BY = 21 * 60;
|
||||
/** 머무는 시간을 안 적었을 때. 0 으로 두면 한 시각에 칸이 겹쳐 쌓인다. */
|
||||
const PLAN_DEFAULT_STAY = 60;
|
||||
/** 출발 시각을 안 적었을 때. 체크아웃 뒤 움직이는 시각을 기본으로 잡는다. */
|
||||
const PLAN_DEFAULT_START = '10:00';
|
||||
|
||||
/** 계절 탭 순서. 데이터에 있는 계절만 이 순서로 세운다 — 붙여넣은 순서대로 두면 겨울이 맨 앞에 온다. */
|
||||
const SEASON_ORDER = ['봄', '여름', '가을', '겨울'];
|
||||
|
||||
/** "HH:MM" → 자정부터의 분. 형식이 아니면 undefined — 지어내지 않는다. */
|
||||
export function minutesOfTime(time: string): number | undefined {
|
||||
const match = /^(\d{1,2}):(\d{2})$/.exec(time.trim());
|
||||
if (!match) return undefined;
|
||||
const hour = Number(match[1]);
|
||||
const minute = Number(match[2]);
|
||||
if (hour > 23 || minute > 59) return undefined;
|
||||
return hour * 60 + minute;
|
||||
}
|
||||
|
||||
export function timeOfMinutes(total: number): string {
|
||||
const wrapped = ((total % 1440) + 1440) % 1440;
|
||||
return `${String(Math.floor(wrapped / 60)).padStart(2, '0')}:${String(wrapped % 60).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
export interface PlannedStop {
|
||||
stop: PlannerStop;
|
||||
/** 도착 시각 "HH:MM". */
|
||||
time: string;
|
||||
/** 떠나는 시각 "HH:MM". */
|
||||
until: string;
|
||||
/** 앞 칸에서 오는 데 걸린 분. 0 이면 화면이 이동 줄을 그리지 않는다. */
|
||||
move: number;
|
||||
}
|
||||
|
||||
export interface PlannedDay {
|
||||
stops: PlannedStop[];
|
||||
/** 하루가 시작·끝나는 시각. 카드 머리에 "09:30–16:40" 으로 뜬다. */
|
||||
from: string;
|
||||
to: string;
|
||||
/** 총 소요(분) — 이동 시간까지 포함한다. */
|
||||
totalMinutes: number;
|
||||
/** 21시 상한에 걸려 못 넣은 칸 수. 숨기지 않고 화면에 밝힌다. */
|
||||
dropped: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 코스 하나 → 시각이 박힌 하루.
|
||||
*
|
||||
* 정거장 순서는 사장님이 적은 그대로다(적은 순서가 곧 도는 순서다). 출발 시각부터
|
||||
* 이동·머무는 시간을 누적해 칸마다 도착·출발 시각을 박고, 상한을 넘기는 칸은 버린다 —
|
||||
* 넘겨서라도 다 넣으면 자정에 끝나는 일정이 나온다.
|
||||
*/
|
||||
export function planDay(item: PlannerItem): PlannedDay {
|
||||
const start = minutesOfTime(item.startTime ?? '') ?? minutesOfTime(PLAN_DEFAULT_START) ?? 600;
|
||||
const stops: PlannedStop[] = [];
|
||||
let clock = start;
|
||||
let dropped = 0;
|
||||
|
||||
for (const stop of item.stops ?? []) {
|
||||
const move = Math.max(0, stop.moveMinutes ?? 0);
|
||||
const stay = Math.max(1, stop.minutes ?? PLAN_DEFAULT_STAY);
|
||||
const arrive = clock + move;
|
||||
if (arrive + stay > PLAN_ENDS_BY) {
|
||||
dropped += 1;
|
||||
continue;
|
||||
}
|
||||
stops.push({stop, time: timeOfMinutes(arrive), until: timeOfMinutes(arrive + stay), move});
|
||||
clock = arrive + stay;
|
||||
}
|
||||
|
||||
return {
|
||||
stops,
|
||||
from: timeOfMinutes(start),
|
||||
to: timeOfMinutes(clock),
|
||||
totalMinutes: clock - start,
|
||||
dropped,
|
||||
};
|
||||
}
|
||||
|
||||
/** 데이터에 실제로 있는 계절만, 봄·여름·가을·겨울 순으로. 그 밖의 값(장마·연중)은 뒤에 붙인다. */
|
||||
export function plannerSeasons(items: PlannerItem[]): string[] {
|
||||
const seen: string[] = [];
|
||||
for (const item of items) {
|
||||
const season = item.season?.trim();
|
||||
if (season && !seen.includes(season)) seen.push(season);
|
||||
}
|
||||
return seen.sort((a, b) => {
|
||||
const ai = SEASON_ORDER.indexOf(a);
|
||||
const bi = SEASON_ORDER.indexOf(b);
|
||||
return (ai < 0 ? SEASON_ORDER.length : ai) - (bi < 0 ? SEASON_ORDER.length : bi);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 그 계절의 추천 코스 — 순위대로 최대 세 개.
|
||||
*
|
||||
* ★ 셋에서 끊는다. 넷째부터는 아무도 안 고르고, 화면에서는 "추천"이 아니라 목록이 된다.
|
||||
* ★ rank 를 안 적었으면 붙여넣은 순서가 순위다 — 순위 없는 코스를 1위로 올리지 않는다.
|
||||
*/
|
||||
export function plannerTop(items: PlannerItem[], season?: string): PlannerItem[] {
|
||||
const picked = season ? items.filter((item) => item.season?.trim() === season) : [...items];
|
||||
picked.sort((a, b) => (a.rank ?? Number.MAX_SAFE_INTEGER) - (b.rank ?? Number.MAX_SAFE_INTEGER));
|
||||
return picked.slice(0, 3);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type {TemplateLook} from './builder';
|
||||
import type {
|
||||
FactStatus,
|
||||
LinkChannel,
|
||||
@@ -229,6 +230,15 @@ export interface SiteTheme {
|
||||
accent: string;
|
||||
};
|
||||
fontStyle: string;
|
||||
/**
|
||||
* 템플릿의 생김새 — 서체 · 모서리 · 테두리 두께 · 그림자 · 섹션 여백.
|
||||
*
|
||||
* ★ 이 필드가 없던 동안 발행본은 **색만** 템플릿을 따랐다. 사장님이 레트로(간판체)를 골라도
|
||||
* 발행 페이지는 늘 같은 고딕·명조로 나갔다 — 캔버스와 발행본이 다르게 보이는 가장 큰 이유였다.
|
||||
* ★ 값은 전부 CSS 에 그대로 들어가는 문자열이다(`TemplateLook`). 렌더러는 이걸 `--tpl-*` 로
|
||||
* 내려보내기만 한다. 비어 있으면 렌더러 기본 서체로 떨어진다 — 화면이 깨지지 않는다.
|
||||
*/
|
||||
look?: TemplateLook;
|
||||
/** 섹션 순서와 노출 여부. 관리자 에디터의 좌측 패널이 만든 결과 그대로. */
|
||||
sections: SectionSetting[];
|
||||
}
|
||||
@@ -258,4 +268,13 @@ export interface SectionSetting {
|
||||
* ★ 줄바꿈이 문단 구분이다. 렌더러가 빈 줄을 기준으로 <p> 를 나눈다.
|
||||
*/
|
||||
body?: string;
|
||||
/**
|
||||
* 붙여넣기 아이템(가요·일력·승차권·인물…)의 원문 JSON.
|
||||
*
|
||||
* ★ body·variantId 와 같은 사연이다 — 이 필드가 없으면 사장님이 붙여넣은 곡 목록이
|
||||
* payload 경계에서 버려져 빌더에서는 보이는데 발행본에는 없다.
|
||||
* ★ **문자열 그대로** 싣는다. 서버는 파싱하지 않는다 — 렌더러가 `parseSectionData()`
|
||||
* (shared/lib/section-data.ts)로 읽고, 깨진 JSON 이면 그 섹션만 조용히 비운다.
|
||||
*/
|
||||
data?: string;
|
||||
}
|
||||
Reference in new issue
Block a user