Files
web-temp/layers/components/blocks/VisualContent.vue
2025-09-16 18:24:35 +09:00

37 lines
875 B
Vue

<script setup lang="ts">
interface Props {
tag: string
text?: string
imageSrc?: any
imageClass?: string
}
const props = defineProps<Props>()
const sanitizedContent = computed(() => {
return props.text?.replace(/\n/g, '<br/>') || ''
})
</script>
<template>
<component :is="tag" v-bind="$attrs">
<template v-if="imageSrc && 'mobileSrc' in imageSrc">
<!-- 모바일 이미지 (sm 미만) -->
<img
v-if="imageSrc.mobileSrc"
:src="imageSrc.mobileSrc"
:alt="text"
:class="`${props.imageClass} sm:hidden`"
/>
<!-- PC 이미지 (sm 이상) -->
<img
v-if="imageSrc.pcSrc"
:src="imageSrc.pcSrc"
:alt="text"
:class="`${props.imageClass} hidden sm:block`"
/>
</template>
<span v-else-if="text" v-dompurify-html="sanitizedContent" />
</component>
</template>