ff-webpage/components/base/ListItem.vue

75 lines
2.5 KiB
Vue
Raw Normal View History

2024-11-03 15:34:48 +01:00
<template>
2024-11-05 14:41:48 +01:00
<NuxtLink
2025-02-14 13:57:55 +01:00
class="w-full h-fit p-2 bg-white shadow-md border border-gray-200 rounded-md justify-start items-start flex"
2024-11-05 14:41:48 +01:00
:class="allowNavigation ? '' : 'pointer-events-none'"
:to="`${urlOverwrite ?? $route.path}/${data?.slug}`"
>
2025-02-14 13:57:55 +01:00
<h1 v-if="itemIndex" class="min-w-20 w-20 sm:min-w-24 sm:w-24 text-center text-black text-4xl my-auto">
{{ itemIndex }}.
2024-11-05 14:41:48 +01:00
</h1>
2025-02-14 13:57:55 +01:00
<div class="grow shrink basis-0 flex-col justify-center items-center flex overflow-hidden">
2024-11-05 14:41:48 +01:00
<h1 class="w-full">{{ 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 }}
2024-11-05 14:41:48 +01:00
</p>
2025-02-14 13:57:55 +01:00
<p class="w-full text-[#5c5c5c] line-clamp-2 overflow-hidden">
2024-11-05 14:41:48 +01:00
{{ data?.description }}
</p>
</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
2025-02-14 13:57:55 +01:00
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>,
2024-11-05 14:41:48 +01:00
numberOverwrite: { type: Number, default: undefined },
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>