<template>
  <UPage>
    <UPageBody>
      <UContainer>
        <UChangelogVersions :versions="newsPost" />
      </UContainer>
    </UPageBody>
  </UPage>
</template>

<script lang="ts" setup>
import type { ChangelogVersionProps } from "@nuxt/ui";

const { data: events } = await useAsyncData("events", () =>
  queryCollection("events")
    .where("draft", "=", false)
    .order("date", "DESC")
    .limit(3)
    .all()
);

// 将 news 数据转换成 UBlogPosts 可用格式
const newsPost = computed<ChangelogVersionProps[]>(() =>
  (events.value || []).map((evt: any) => ({
    title: evt.title,
    description: evt.description,
    image: evt.cover,
    date: evt.date,
    to: evt.path, // ✅ 建议加路由跳转
  }))
);
</script>

<style></style>
