This commit introduces a draft system for the 'events' and 'news' collections. A `draft` boolean field has been added to the content schema, and frontend queries are now updated to only fetch and display content where `draft` is `false`. This allows content to be created and saved without being publicly visible, improving the publishing workflow.
35 lines
760 B
Vue
35 lines
760 B
Vue
<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>
|