ff-webpage/components/dynamicZone/FileDownload.vue

42 lines
1.2 KiB
Vue
Raw Normal View History

2025-01-18 11:30:46 +01:00
<template>
<div v-if="showComponent" class="flex flex-col gap-2 w-full min-h-fit max-w-4xl mx-auto">
2025-02-14 13:57:55 +01:00
<iframe v-if="data?.file.mime == 'application/pdf'" :src="baseUrl + data.file.url" class="w-full h-[90vh]"></iframe>
2025-01-18 11:30:46 +01:00
<NuxtPicture
2025-02-14 13:57:55 +01:00
v-if="data?.file.mime.includes('image')"
2025-01-18 11:30:46 +01:00
loading="lazy"
class="w-full object-cover object-center mx-auto"
:src="baseUrl + data?.file.url"
:imgAttrs="{ class: 'w-full h-full object-cover object-center' }"
/>
<a
2025-02-14 13:57:55 +01:00
v-if="data?.enable_download"
:href="baseUrl + data?.file.url"
:download="data?.file.name"
2025-01-18 11:30:46 +01:00
target="_blank"
class="w-fit text-primary underline"
>
Datei herunterladen
</a>
</div>
</template>
<script setup lang="ts">
import type { PropType } from "vue";
2025-02-14 13:57:55 +01:00
import type DynamicZoneFileDownload from "../../types/component/dynamic-zone/fileDownload";
2025-01-18 11:30:46 +01:00
const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url;
const props = defineProps({
data: Object as PropType<DynamicZoneFileDownload>,
});
const showComponent = computed(() => {
2025-02-14 13:57:55 +01:00
if (props.data?.file.mime == "application/pdf" || props.data?.file.mime.includes("image")) {
2025-01-18 11:30:46 +01:00
return true;
} else {
2025-02-14 13:57:55 +01:00
return props.data?.enable_download;
2025-01-18 11:30:46 +01:00
}
});
</script>