From acbbc595b23b49193281730d681df623b7aa0d4e Mon Sep 17 00:00:00 2001 From: nurRiyad Date: Fri, 23 Dec 2022 02:08:59 +0600 Subject: [PATCH] fix filter and fetch Signed-off-by: nurRiyad --- pages/[...slug].vue | 7 +++---- pages/index.vue | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pages/[...slug].vue b/pages/[...slug].vue index c72210f..2a2ad52 100644 --- a/pages/[...slug].vue +++ b/pages/[...slug].vue @@ -11,12 +11,11 @@ const path = computed(() => { return route.path || ""; }); -const { data } = await useAsyncData("page-data", () => - queryContent(`${path.value}`).findOne() -); +const data = useState("blogData"); const content = computed(() => { - return data.value as ParsedContent; + const allpost = (data.value as Array) || []; + return allpost.find((post) => post._path === path.value) || {}; }); diff --git a/pages/index.vue b/pages/index.vue index eafc9fa..452d7ef 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -12,8 +12,7 @@ const getTopCategory = computed(() => { dir: post._dir, }; }); - const uniqType = new Set(alltypes); - return uniqType; + return [...new Map(alltypes.map((item) => [item["dir"], item])).values()]; }); // get all post in recent time order