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

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

const { data: news } = await useAsyncData("news", () =>
  queryCollection("news").order("date", "DESC").all()
);

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

<style></style>
