31 lines
859 B
JavaScript
31 lines
859 B
JavaScript
import { listAdminPosts } from '../server/repositories/content-repository.js'
|
|
import {
|
|
createPostThumbnailForImageUrl,
|
|
getExistingPostThumbnailUrl,
|
|
getPostThumbnailUrl
|
|
} from '../server/utils/post-thumbnail-image.js'
|
|
|
|
const posts = await listAdminPosts()
|
|
const featuredImageUrls = [...new Set(posts
|
|
.map((post) => post.featuredImage)
|
|
.filter((url) => getPostThumbnailUrl(url)))]
|
|
let createdCount = 0
|
|
let skippedCount = 0
|
|
|
|
for (const imageUrl of featuredImageUrls) {
|
|
if (getExistingPostThumbnailUrl(imageUrl)) {
|
|
skippedCount += 1
|
|
continue
|
|
}
|
|
|
|
const thumbnailUrl = await createPostThumbnailForImageUrl(imageUrl)
|
|
|
|
if (thumbnailUrl) {
|
|
createdCount += 1
|
|
} else {
|
|
skippedCount += 1
|
|
}
|
|
}
|
|
|
|
process.stdout.write(`게시물 대표 이미지 카드 썸네일 생성 완료: 생성 ${createdCount}개, 건너뜀 ${skippedCount}개\n`)
|