diff --git a/src/pages/archive.astro b/src/pages/archive.astro
index 52ced049..90ede242 100644
--- a/src/pages/archive.astro
+++ b/src/pages/archive.astro
@@ -3,12 +3,12 @@ import ArchivePanel from "@components/ArchivePanel.svelte";
import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation";
import MainGridLayout from "@layouts/MainGridLayout.astro";
-import { getSortedPosts } from "../utils/content-utils";
+import { getSortedPostsList } from "../utils/content-utils";
-const sortedPosts = await getSortedPosts();
+const sortedPostsList = await getSortedPostsList();
---
-
+
diff --git a/src/utils/content-utils.ts b/src/utils/content-utils.ts
index a39a02f6..f30b8903 100644
--- a/src/utils/content-utils.ts
+++ b/src/utils/content-utils.ts
@@ -1,9 +1,10 @@
-import { getCollection } from "astro:content";
+import { type CollectionEntry, getCollection } from "astro:content";
import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation";
import { getCategoryUrl } from "@utils/url-utils.ts";
-export async function getSortedPosts() {
+// // Retrieve posts and sort them by publication date
+async function getRawSortedPosts() {
const allBlogPosts = await getCollection("posts", ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
});
@@ -13,6 +14,11 @@ export async function getSortedPosts() {
const dateB = new Date(b.data.published);
return dateA > dateB ? -1 : 1;
});
+ return sorted;
+}
+
+export async function getSortedPosts() {
+ const sorted = await getRawSortedPosts();
for (let i = 1; i < sorted.length; i++) {
sorted[i].data.nextSlug = sorted[i - 1].slug;
@@ -25,7 +31,21 @@ export async function getSortedPosts() {
return sorted;
}
+export type PostForList = {
+ slug: string;
+ data: CollectionEntry<"posts">["data"];
+};
+export async function getSortedPostsList(): Promise {
+ const sortedFullPosts = await getRawSortedPosts();
+ // delete post.body
+ const sortedPostsList = sortedFullPosts.map((post) => ({
+ slug: post.slug,
+ data: post.data,
+ }));
+
+ return sortedPostsList;
+}
export type Tag = {
name: string;
count: number;