/** @type {string} DB/API에만 쓰는 제목 없음 표시(폼·목록에는 빈 문자열로 노출) */ export const ADMIN_POST_PLACEHOLDER_TITLE = '(제목 없음)' /** * 제목 없음 플레이스홀더 여부 * @param {string | null | undefined} title - 제목 * @returns {boolean} */ export const isAdminPostPlaceholderTitle = (title) => { const t = String(title ?? '').trim() return !t || t === ADMIN_POST_PLACEHOLDER_TITLE } /** * 관리자 폼·목록에 표시할 제목(플레이스홀더는 빈 문자열) * @param {string | null | undefined} title - DB/API 제목 * @returns {string} */ export const toAdminPostFormTitle = (title) => { if (isAdminPostPlaceholderTitle(title)) { return '' } return String(title).trim() } /** * API 저장용 제목(비어 있으면 플레이스홀더) * @param {string | null | undefined} title - 폼 제목 * @returns {string} */ export const toAdminPostStoredTitle = (title) => { const t = String(title ?? '').trim() return t.length ? t : ADMIN_POST_PLACEHOLDER_TITLE } /** * 임시 슬러그 여부(d + 24~25자리 hex) * @param {string | null | undefined} slug - 슬러그 * @returns {boolean} */ export const isAdminPostDraftPlaceholderSlug = (slug) => /^d[0-9a-f]{24,25}$/i.test(String(slug ?? '').trim())