이미지 파생 파일 생성 안정화
This commit is contained in:
@@ -1,14 +1,32 @@
|
||||
import { z } from 'zod'
|
||||
import { normalizeMarkdownContent } from '../../lib/markdown-content-normalizer.js'
|
||||
import {
|
||||
isPageCoverThumbnailUrl,
|
||||
isPostBodyThumbnailUrl,
|
||||
isPostCardThumbnailUrl
|
||||
} from '../../lib/post-card-thumbnail-url.js'
|
||||
import { pageStatusSchema } from './content-schema.js'
|
||||
|
||||
/**
|
||||
* 자동 생성 파생 이미지 URL인지 확인한다.
|
||||
* @param {string|null|undefined} imageUrl - 검사할 이미지 URL
|
||||
* @returns {boolean} 자동 생성 이미지이면 true
|
||||
*/
|
||||
const isGeneratedThumbnailUrl = (imageUrl) => isPostCardThumbnailUrl(imageUrl)
|
||||
|| isPostBodyThumbnailUrl(imageUrl)
|
||||
|| isPageCoverThumbnailUrl(imageUrl)
|
||||
|
||||
export const adminPageInputSchema = z.object({
|
||||
title: z.string().trim().min(1),
|
||||
slug: z.string().trim().min(1).regex(/^[a-z0-9가-힣]+(?:[-_][a-z0-9가-힣]+)*$/),
|
||||
renderMode: z.enum(['markdown', 'html_document']).default('html_document'),
|
||||
status: pageStatusSchema.default('published'),
|
||||
content: z.string().default(''),
|
||||
featuredImage: z.string().trim().nullable().default(null),
|
||||
featuredImage: z.string()
|
||||
.trim()
|
||||
.nullable()
|
||||
.default(null)
|
||||
.refine((value) => !isGeneratedThumbnailUrl(value), '자동 생성 이미지는 페이지 커버로 사용할 수 없습니다.'),
|
||||
isListed: z.boolean().optional().default(false),
|
||||
isFeatured: z.boolean().optional().default(false),
|
||||
listingSection: z.string().trim().max(80).optional().default(''),
|
||||
|
||||
Reference in New Issue
Block a user