💄 Better history

This commit is contained in:
LittleSheep 2024-01-20 23:38:08 +08:00
parent c80003459e
commit 24292348d3
3 changed files with 16 additions and 7 deletions

View File

@ -2,11 +2,14 @@
import RootLayout from "../layouts/RootLayout.astro"; import RootLayout from "../layouts/RootLayout.astro";
import { client } from "../..//tina/__generated__/client"; import { client } from "../..//tina/__generated__/client";
import { TinaMarkdown } from "tinacms/dist/rich-text";
const eventsResponse = await client.queries.eventConnection(); const eventsResponse = await client.queries.eventConnection();
const events = eventsResponse.data.eventConnection.edges const events = eventsResponse.data.eventConnection.edges
?.reverse() ?.sort((a, b) =>
new Date(a?.node?.date ?? 0).getTime() <= new Date(b?.node?.date ?? 0).getTime()
? -1
: 0
)
.map((event) => { .map((event) => {
return { ...event?.node, slug: event?.node?._sys.filename }; return { ...event?.node, slug: event?.node?._sys.filename };
}); });
@ -113,7 +116,9 @@ const events = eventsResponse.data.eventConnection.edges
年。自那年起我们一直在开发让人喜欢的开源软件。在我们这里,“取之于开源,用之于开源” 年。自那年起我们一直在开发让人喜欢的开源软件。在我们这里,“取之于开源,用之于开源”
不仅是原则,更是我们信仰的座右铭。 不仅是原则,更是我们信仰的座右铭。
</p> </p>
<a href="#history" class="btn btn-primary btn-md pl-[24px]">查看「岁月史书」</a> <a href="#history" class="btn btn-primary btn-md pl-[24px]"
>查看「岁月史书」</a
>
</div> </div>
</div> </div>
</div> </div>
@ -152,9 +157,7 @@ const events = eventsResponse.data.eventConnection.edges
</div> </div>
<div class="timeline-end timeline-box"> <div class="timeline-end timeline-box">
<h2 class="font-bold">{item.title}</h2> <h2 class="font-bold">{item.title}</h2>
<div class="line-clamp-2"> <div class="line-clamp-2">{item.description}</div>
<TinaMarkdown content={item._body} />
</div>
</div> </div>
{idx < events?.length - 1 && <hr />} {idx < events?.length - 1 && <hr />}
</li> </li>

View File

@ -29,6 +29,12 @@ const Event: Collection = {
name: "author", name: "author",
collections: ["author"], collections: ["author"],
}, },
{
type: "string",
label: "Description",
name: "description",
required: true,
},
{ {
type: "datetime", type: "datetime",
label: "Published Date", label: "Published Date",

File diff suppressed because one or more lines are too long