From 2edd734e94510e5aee29e5a017fd4e2afc8ae850 Mon Sep 17 00:00:00 2001 From: nurRiyad Date: Tue, 20 Dec 2022 00:51:25 +0600 Subject: [PATCH] make archive page dynamic Signed-off-by: nurRiyad --- components/ArchievCard.vue | 30 ++++++++++++++++++++++++++---- components/ArchivePostCard.vue | 19 ------------------- pages/archive.vue | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 57 insertions(+), 26 deletions(-) delete mode 100644 components/ArchivePostCard.vue diff --git a/components/ArchievCard.vue b/components/ArchievCard.vue index 299c038..253c4bb 100644 --- a/components/ArchievCard.vue +++ b/components/ArchievCard.vue @@ -1,8 +1,30 @@ + + diff --git a/components/ArchivePostCard.vue b/components/ArchivePostCard.vue deleted file mode 100644 index a56cf85..0000000 --- a/components/ArchivePostCard.vue +++ /dev/null @@ -1,19 +0,0 @@ - diff --git a/pages/archive.vue b/pages/archive.vue index 3d730be..a7dcd4e 100644 --- a/pages/archive.vue +++ b/pages/archive.vue @@ -2,16 +2,44 @@ definePageMeta({ layout: "list", }); + const { data } = await useAsyncData("home", () => queryContent("/").find()); + +const getAllPost = computed(() => { + const allpost = data.value || []; + const alltypes = allpost.map((post) => { + return { + title: post.title, + path: post._path, + date: post.date as string, + type: post.type, + }; + }); + alltypes.sort(function (a, b) { + const c = new Date(a.date); + const d = new Date(b.date); + return c < d ? 1 : -1; + }); + return alltypes; +});