fix. utils 함수 변경, 클래스명 수정

This commit is contained in:
clkim
2025-10-31 17:33:15 +09:00
parent 83124d56eb
commit 3569ca66c8
17 changed files with 89 additions and 104 deletions

View File

@@ -1,10 +1,12 @@
/**
* 스타일 유틸리티 함수
* @description 스타일 처리에 필요한 유틸리티 함수를 제공합니다.
* @description ui 처리에 필요한 유틸리티 함수를 제공합니다.
*/
import { isTypeVideo } from '#layers/utils/dataUtil'
import type {
PageDataResourceGroups,
PageDataResourceGroup,
PageDataResourceGroupResPath,
} from '#layers/types/api/pageData'
@@ -128,3 +130,26 @@ export const getPaginationClass = (
'--pagination-disabled': paginationDisabled,
}
}
/**
* 미디어 이미지를 반환합니다. (이미지 / 유튜브 썸네일)
* @param resourceGroups - 미디어 리소스 그룹 객체
* @param quality - 썸네일 품질
* @returns 미디어 이미지 소스 (이미지 / 유튜브 썸네일)
*/
export const getMediaImgSrc = (
resourceGroups: PageDataResourceGroup,
quality: 'default' | 'medium' | 'high' | 'standard' | 'maxres' = 'high'
): string => {
if (!resourceGroups) return ''
const mediaSrc = resourceGroups?.display?.text
const mediaType = resourceGroups?.resource_type
if (isTypeVideo(mediaType) && mediaSrc) {
const thumbnailUrl = getYouTubeThumbnail(mediaSrc, quality)
return thumbnailUrl
}
return mediaSrc || ''
}