ff-webpage/components/base/ListImageItem.vue

94 lines
3.1 KiB
Vue
Raw Normal View History

2024-11-03 15:34:48 +01:00
<template>
2024-11-05 14:41:48 +01:00
<NuxtLink
class="w-full sm:w-72 h-96 rounded-lg shadow-md border border-gray-200 flex-col justify-start items-start inline-flex overflow-hidden"
:class="allowNavigation ? '' : 'pointer-events-none'"
:to="`${urlOverwrite ?? $route.path}/${data?.slug}`"
>
2025-02-14 13:57:55 +01:00
<div class="w-full h-56 relative">
<NuxtPicture
loading="lazy"
class="w-full h-full object-cover object-center"
:src="data?.image?.url || logo?.url ? baseUrl + (data?.image?.url ?? logo?.url) : '/favicon.png'"
:imgAttrs="{ class: 'w-full h-full object-cover object-center' }"
/>
<h1
v-if="itemIndex"
class="text-center text-black text-4xl my-auto absolute bottom-2 left-2"
style="text-shadow: 2px 2px 4px white"
>
{{ itemIndex }}.
</h1>
</div>
2024-11-06 08:59:07 +01:00
<div class="w-full h-44 relative bg-white px-2 py-5 flex flex-col justify-start items-start gap-2 overflow-y-auto">
2025-01-16 13:23:23 +01:00
<h1>
{{ data?.title }}
</h1>
2025-02-19 13:10:27 +01:00
<p v-if="itemDate && lookup?.show_date" class="w-full text-[#5c5c5c]">
2025-02-14 13:57:55 +01:00
{{ itemDate }}
2025-01-16 13:23:23 +01:00
</p>
2025-02-14 13:57:55 +01:00
<p class="w-full text-[#5c5c5c] line-clamp-2 overflow-hidden">
2024-11-06 08:59:07 +01:00
{{ data?.description }}
</p>
2024-11-05 14:41:48 +01:00
</div>
</NuxtLink>
2024-11-03 15:34:48 +01:00
</template>
<script setup lang="ts">
import type { PropType } from "vue";
import type BaseCollection from "~/types/collection/baseCollection";
2025-02-14 13:57:55 +01:00
import type Lookup from "../../types/collection/lookup";
2024-11-03 15:34:48 +01:00
2024-11-05 18:31:12 +01:00
const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url;
2024-11-05 14:41:48 +01:00
2025-02-14 13:57:55 +01:00
const { logo } = await provideGlobal();
const props = defineProps({
2024-11-03 15:34:48 +01:00
data: Object as PropType<BaseCollection>,
2025-02-14 13:57:55 +01:00
lookup: Object as PropType<Lookup>,
2025-01-16 13:23:23 +01:00
numberOverwrite: { type: Number, default: undefined },
2024-11-05 14:41:48 +01:00
allowNavigation: { type: Boolean, default: false },
urlOverwrite: { type: String, default: undefined },
2024-11-03 15:34:48 +01:00
});
2025-02-14 13:57:55 +01:00
const itemIndex = computed(() => {
if (props.lookup?.items_with_number != "none") {
return props.numberOverwrite;
} else if (props.lookup?.list_with_date != "none") {
return new Date(props.data?.date ?? "").toLocaleString("de-DE", {
day: "2-digit",
});
} else {
return undefined;
}
});
const itemDate = computed(() => {
let config = {
year:
props.lookup?.list_with_date == "none" || props.lookup?.items_with_number != "none"
? ("numeric" as const)
: undefined,
month:
props.lookup?.list_with_date != "by-month" || props.lookup?.items_with_number != "none"
? ("long" as const)
: undefined,
day:
props.lookup?.list_with_date == "none" || props.lookup?.items_with_number != "none"
? ("2-digit" as const)
: undefined,
2025-02-19 13:10:27 +01:00
minute: props.data?.date.includes("T") ? ("2-digit" as const) : undefined,
hour: props.data?.date.includes("T") ? ("2-digit" as const) : undefined,
2025-02-14 13:57:55 +01:00
};
if (Object.values(config).filter((c) => c).length != 0) {
//(props.lookup?.list_with_date != "none" || props.lookup?.show_date)
return (
new Date(props.data?.date ?? "").toLocaleString("de-DE", config) + (props.data?.date.includes("T") ? "Uhr" : "")
);
} else {
return undefined;
}
});
2024-11-03 15:34:48 +01:00
</script>