diff --git a/pages/tags/[topic].vue b/pages/tags/[topic].vue index 21f4d96..6d0d204 100644 --- a/pages/tags/[topic].vue +++ b/pages/tags/[topic].vue @@ -2,16 +2,59 @@ definePageMeta({ layout: "list", }); -const { data } = await useAsyncData("home", () => queryContent("/").find()); + +const route = useRoute(); + +const routeType = computed(() => { + return route.params.topic || ""; +}); +const { data } = await useAsyncData("home", () => + queryContent(`/${routeType.value}`).find() +); + +const typeName = computed(() => { + const t = data.value?.at(0)?.type || ""; + return t.toUpperCase(); +}); + +const getRecentContent = computed(() => { + const allpost = data.value || []; + const alltypes = allpost.map((post) => { + return { + title: post.title, + description: post.description, + path: post._path, + date: post.date as string, + author: post.author, + }; + }); + + alltypes.sort(function (a, b) { + const c = new Date(a.date); + const d = new Date(b.date); + return c < d ? 1 : -1; + }); + return alltypes; +});