---
import { Image } from "astro:assets"
import { Icon } from "astro-icon/components";
import "dayjs/locale/es";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
const regionNames = new Intl.DisplayNames(['es'], { type: 'region' });

const locale = Astro.currentLocale;
dayjs.extend(utc);
dayjs.locale(locale);

const { data } = Astro.props;
const nicedate = dayjs.utc(data.data.date).format("D MMMM YYYY");
const countryName = data?.data?.country ? regionNames.of(data.data.country) : "";

const locationArray = [data.data.city,countryName]
locationArray.filter(Boolean).join(', ');
---

<div class="bg-[#EBE5D0] text-[#003421] p-10">
  <Icon name="ph:arrow-circle-down-thin" class="text-8xl mb-8" />
  <p class="font-light text-2xl mb-8">
    {locationArray.filter(Boolean).join(', ')}<br />
    ({nicedate}):
  </p>
  <h3 class="text-2xl font-bold mb-8"><a href={`/${locale}/news/${data.id}`}>{data.data.title}</a></h3>

  <div>
    <Image
      src={data.data.thumbnail}
      alt={data.data.title}
      class="aspect-square object-cover"
    />
  </div>
</div>
