We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
baseURL
1 parent cb4fa76 commit d2e2fbaCopy full SHA for d2e2fba
src/runtime/components/Prose/ProseImg.vue
@@ -1,9 +1,12 @@
1
<template>
2
- <img :src="src" :alt="alt" :width="width" :height="height">
+ <img :src="refinedSrc" :alt="alt" :width="width" :height="height">
3
</template>
4
5
<script setup lang="ts">
6
-defineProps({
+import { withBase } from 'ufo'
7
+import { useRuntimeConfig, computed } from '#imports'
8
+
9
+const props = defineProps({
10
src: {
11
type: String,
12
default: ''
@@ -21,4 +24,11 @@ defineProps({
21
24
default: undefined
22
25
}
23
26
})
27
28
+const refinedSrc = computed(() => {
29
+ if (props.src?.startsWith('/') && !props.src.startsWith('//')) {
30
+ return withBase(props.src, useRuntimeConfig().app.baseURL)
31
+ }
32
+ return props.src
33
+})
34
</script>
0 commit comments