2026-08-25 11:42:17 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { ArticleSummary } from '#shared/types/blog'
|
2026-09-11 13:52:13 +02:00
|
|
|
import type { Locale } from '#shared/utils/locale'
|
|
|
|
|
import { localePath } from '#shared/utils/locale'
|
2026-08-25 11:42:17 +02:00
|
|
|
|
2026-09-11 13:52:13 +02:00
|
|
|
const props = withDefaults(defineProps<{ article: ArticleSummary; locale?: Locale }>(), {
|
|
|
|
|
locale: 'it',
|
|
|
|
|
})
|
2026-08-25 11:42:17 +02:00
|
|
|
|
|
|
|
|
const mediaUrl = useMediaUrl()
|
|
|
|
|
const cover = computed(() => mediaUrl(props.article.cover))
|
2026-09-11 13:52:13 +02:00
|
|
|
const href = computed(() => localePath(props.locale, `/blog/${props.article.slug}`))
|
2026-08-25 11:42:17 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<article class="card">
|
2026-08-25 19:04:40 +02:00
|
|
|
<!-- No placeholder box when there is no cover: an empty grey rectangle
|
|
|
|
|
reads as a broken image rather than as a deliberate choice. -->
|
2026-08-26 09:39:05 +02:00
|
|
|
<NuxtLink
|
2026-08-25 19:04:40 +02:00
|
|
|
v-if="cover"
|
2026-08-25 14:23:09 +02:00
|
|
|
class="cover-link"
|
2026-09-11 13:52:13 +02:00
|
|
|
:to="href"
|
2026-08-25 14:23:09 +02:00
|
|
|
tabindex="-1"
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
>
|
2026-08-25 12:22:05 +02:00
|
|
|
<img
|
|
|
|
|
class="cover"
|
|
|
|
|
:src="cover"
|
2026-09-11 11:25:14 +02:00
|
|
|
:alt="article.cover?.alt ?? ''"
|
2026-08-25 12:22:05 +02:00
|
|
|
loading="lazy"
|
|
|
|
|
>
|
2026-08-26 09:39:05 +02:00
|
|
|
</NuxtLink>
|
2026-08-25 11:42:17 +02:00
|
|
|
|
2026-08-25 12:22:05 +02:00
|
|
|
<p v-if="article.category" class="kicker">{{ article.category.name }}</p>
|
2026-08-25 11:42:17 +02:00
|
|
|
|
|
|
|
|
<h2>
|
2026-09-11 13:52:13 +02:00
|
|
|
<NuxtLink :to="href">{{ article.title }}</NuxtLink>
|
2026-08-25 11:42:17 +02:00
|
|
|
</h2>
|
|
|
|
|
|
2026-08-25 12:22:05 +02:00
|
|
|
<p class="kicker date">
|
2026-08-25 14:23:09 +02:00
|
|
|
<time :datetime="isoDate(article.publishedAt)">
|
2026-09-11 13:52:13 +02:00
|
|
|
{{ formatDate(article.publishedAt, locale) }}
|
2026-08-25 14:23:09 +02:00
|
|
|
</time>
|
2026-08-25 11:42:17 +02:00
|
|
|
</p>
|
|
|
|
|
</article>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-08-25 12:22:05 +02:00
|
|
|
.cover-link {
|
|
|
|
|
display: block;
|
|
|
|
|
overflow: hidden;
|
2026-08-25 11:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.cover {
|
|
|
|
|
width: 100%;
|
2026-09-14 14:28:14 +02:00
|
|
|
aspect-ratio: 3 / 2;
|
2026-08-25 11:42:17 +02:00
|
|
|
object-fit: cover;
|
|
|
|
|
background: var(--color-surface);
|
2026-08-25 12:22:05 +02:00
|
|
|
transition: transform 0.4s ease;
|
2026-08-25 11:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
2026-08-25 12:22:05 +02:00
|
|
|
.cover-link:hover .cover {
|
|
|
|
|
transform: scale(1.03);
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-25 19:04:40 +02:00
|
|
|
/* Without a cover the kicker leads the card, so it needs no offset. */
|
|
|
|
|
.cover-link + .kicker,
|
|
|
|
|
.cover-link + h2 {
|
2026-08-25 12:22:05 +02:00
|
|
|
margin-top: 1.1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
margin-top: 0.5rem;
|
|
|
|
|
font-size: 1.35rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 a {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
background-image: linear-gradient(var(--color-ink), var(--color-ink));
|
|
|
|
|
background-size: 0 1px;
|
|
|
|
|
background-position: 0 100%;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
transition: background-size 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 a:hover {
|
|
|
|
|
background-size: 100% 1px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.date {
|
|
|
|
|
margin-top: 0.6rem;
|
|
|
|
|
font-weight: 400;
|
2026-08-25 11:42:17 +02:00
|
|
|
}
|
|
|
|
|
</style>
|