/** จำนวนช่องภาพที่แกลเลอรีแสดงจริง: 1 ภาพหลัก + 2 ภาพย่อย */ export const GALLERY_SLOTS = 3; const THUMB_SLOTS = GALLERY_SLOTS - 1; export type GalleryView = { main: string | null; thumbs: string[]; /** จำนวนรูปที่ยังไม่ถูกแสดง ใช้ทำป้าย "+N" — 0 คือไม่ต้องมีป้าย */ remaining: number; }; /** * แบ่งรูปทั้งหมดเป็นภาพหลัก + ภาพย่อย และนับรูปที่เหลือ * ป้าย "+N" จึงมาจากจำนวนรูปจริง ไม่ใช่ค่าคงที่ในโค้ด */ export function splitGallery(photos: string[]): GalleryView { const [main = null, ...rest] = photos; return { main, thumbs: rest.slice(0, THUMB_SLOTS), remaining: Math.max(rest.length - THUMB_SLOTS, 0), }; }