Skip to content

Commit

Permalink
feat(module): Update image source handling (#121)
Browse files Browse the repository at this point in the history
Added logic to check for props.module.s3Key and set the image source accordingly in Image.vue and Project.vue components. Cover image is now used if available; otherwise, the default image src is used.
  • Loading branch information
nexmoe authored May 4, 2024
1 parent 55ead43 commit c2971ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/module/Image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface Props {
const props = defineProps<Props>()
const flow = inject('flow') as FlowOutput
const text = computed(() => extractTextFromHTML(props.module.content))
const cover = props.module.s3Key ? `https://space.r2.102415.xyz/${props.module.s3Key}` : props.module.image
</script>

<template>
Expand All @@ -34,7 +35,7 @@ const text = computed(() => extractTextFromHTML(props.module.content))
<NuxtImg
class="w-full"
format="webp"
:src="props.module!.image"
:src="cover || undefined"
:alt="module.title"
referrerpolicy="no-referrer"
loading="lazy"
Expand Down
3 changes: 2 additions & 1 deletion components/module/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Props {
}
const props = defineProps<Props>()
const cover = props.module.s3Key ? `https://space.r2.102415.xyz/${props.module.s3Key}` : props.module.image
</script>

<template>
Expand All @@ -20,7 +21,7 @@ const props = defineProps<Props>()
<NuxtImg
width="48px"
height="48px"
:src="props.module.image ?? undefined"
:src="cover || undefined"
loading="lazy"
:alt="props.module.title"
/>
Expand Down

0 comments on commit c2971ec

Please sign in to comment.