Skip to content

Commit

Permalink
fix(markdown): images src with baseURL
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jan 24, 2023
1 parent 383f707 commit 3c683ce
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/runtime/components/Prose/ProseImg.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<template>
<img :src="src" :alt="alt" :width="width" :height="height">
<img :src="refinedSrc" :alt="alt" :width="width" :height="height">
</template>

<script setup lang="ts">
defineProps({
import { withBase } from 'ufo'
import { useRuntimeConfig, computed } from '#imports'
const props = defineProps({
src: {
type: String,
default: ''
Expand All @@ -21,4 +24,11 @@ defineProps({
default: undefined
}
})
const refinedSrc = computed(() => {
if (props.src?.startsWith('/') && !props.src.startsWith('//')) {
return withBase(props.src, useRuntimeConfig().app.baseURL)
}
return props.src
})
</script>

0 comments on commit 3c683ce

Please sign in to comment.