본문 이미지 최적화·라이트박스·번호형 페이지네이션 반영 (v1.10.3)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { createError, readBody } from 'h3'
|
||||
import { requireAdminSession } from '../../../../utils/admin-auth'
|
||||
import { createPostThumbnailForImageUrl } from '../../../../utils/post-thumbnail-image.js'
|
||||
import {
|
||||
createPostBodyThumbnailForImageUrl,
|
||||
createPostThumbnailForImageUrl
|
||||
} from '../../../../utils/post-thumbnail-image.js'
|
||||
|
||||
/**
|
||||
* 게시물 대표 이미지 카드 썸네일 재생성 API
|
||||
* 게시물 이미지 파생 파일 재생성 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Promise<{ thumbnailUrl: string }>} 생성된 썸네일 URL
|
||||
*/
|
||||
@@ -11,12 +14,17 @@ export default defineEventHandler(async (event) => {
|
||||
requireAdminSession(event)
|
||||
|
||||
const body = await readBody(event)
|
||||
const thumbnailUrl = await createPostThumbnailForImageUrl(body?.url)
|
||||
const kind = body?.kind === 'body' ? 'body' : 'card'
|
||||
const thumbnailUrl = kind === 'body'
|
||||
? await createPostBodyThumbnailForImageUrl(body?.url)
|
||||
: await createPostThumbnailForImageUrl(body?.url)
|
||||
|
||||
if (!thumbnailUrl) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: '카드 썸네일을 만들 수 있는 게시물 대표 이미지가 아닙니다.'
|
||||
message: kind === 'body'
|
||||
? '본문 표시용 이미지를 만들 수 있는 게시물 이미지가 아닙니다.'
|
||||
: '카드 썸네일을 만들 수 있는 게시물 대표 이미지가 아닙니다.'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user