2023-07-15 10:32:48 +02:00
|
|
|
<template>
|
2023-09-29 13:30:13 +02:00
|
|
|
<img class="rounded-lg" :src="refinedSrc" :alt="alt" :width="width" :height="height" loading="lazy" />
|
2023-07-15 10:32:48 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { withBase } from 'ufo'
|
|
|
|
import { useRuntimeConfig, computed } from '#imports'
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
src: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
alt: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: undefined
|
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: undefined
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const refinedSrc = computed(() => {
|
|
|
|
if (props.src?.startsWith('/') && !props.src.startsWith('//')) {
|
|
|
|
return withBase(props.src, useRuntimeConfig().app.baseURL)
|
|
|
|
}
|
|
|
|
return props.src
|
|
|
|
})
|
|
|
|
</script>
|