Ghost형 툴바·초안 자동 저장·발행 모달, private 제거, 미디어 모달 통합, 발행일·수정일 표시 설정과 DB 마이그레이션 025·026을 반영한다. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
import { z } from 'zod'
|
|
import { ADMIN_POST_PLACEHOLDER_TITLE } from '../../lib/admin-post-title.js'
|
|
import { normalizeMarkdownContent } from '../../lib/markdown-content-normalizer.js'
|
|
import { postStatusSchema } from './content-schema.js'
|
|
|
|
export const adminPostInputSchema = z.object({
|
|
title: z.preprocess((val) => {
|
|
const t = String(val ?? '').trim()
|
|
return t.length ? t : ADMIN_POST_PLACEHOLDER_TITLE
|
|
}, z.string().min(1)),
|
|
slug: z.string().trim().min(1).regex(/^[a-z0-9가-힣]+(?:-[a-z0-9가-힣]+)*$/),
|
|
content: z.preprocess(normalizeMarkdownContent, z.string()).default(''),
|
|
excerpt: z.string().default(''),
|
|
featuredImage: z.string().trim().nullable().default(null),
|
|
isFeatured: z.boolean().default(false),
|
|
seoTitle: z.string().trim().default(''),
|
|
seoDescription: z.string().trim().default(''),
|
|
canonicalUrl: z.string().trim().url().or(z.literal('')).default(''),
|
|
noindex: z.boolean().default(false),
|
|
ogImage: z.string().trim().nullable().default(null),
|
|
status: z.preprocess((val) => (val === 'private' ? 'draft' : val), postStatusSchema).default('draft'),
|
|
publishedAt: z.string().datetime().nullable().default(null),
|
|
tags: z.array(z.string().trim().min(1)).default([])
|
|
})
|
|
|
|
/**
|
|
* 관리자 게시물 입력값 정리
|
|
* @param {unknown} body - 요청 본문
|
|
* @returns {import('zod').SafeParseReturnType<unknown, Object>} 검증 결과
|
|
*/
|
|
export const parseAdminPostInput = (body) => adminPostInputSchema.safeParse(body)
|