From fee9376734b7a9325d74504e98bbd78e480c37d8 Mon Sep 17 00:00:00 2001 From: Daveed Date: Fri, 6 Dec 2024 18:55:25 -0500 Subject: [PATCH] dizplaying tags page --- src/components/Footer.astro | 2 +- src/interfaces/Store.ts | 1 + src/layouts/TagPosts.astro | 16 ++++++++++++---- src/pages/search.astro | 2 +- src/pages/tags/[tag]/[page].astro | 30 +++++++++++++++++++++++------- src/pages/tags/[tag]/index.astro | 21 ++++++++++++++------- src/utils/getPostsByTag.ts | 2 +- 7 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 4b59621..4695a08 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -6,7 +6,7 @@ const currentYear = new Date().getFullYear(); export interface Props { noMarginTop?: boolean; - activeNav: string; + activeNav?: string; } const { activeNav, noMarginTop = false } = Astro.props; diff --git a/src/interfaces/Store.ts b/src/interfaces/Store.ts index 0816c6a..4b3a7d1 100644 --- a/src/interfaces/Store.ts +++ b/src/interfaces/Store.ts @@ -8,6 +8,7 @@ export default interface Store { slug: string; products: { data: [] }; URLS: { Label: string, URL: string, }[]; + SEO: {}; Logo: { id: string, url: string, diff --git a/src/layouts/TagPosts.astro b/src/layouts/TagPosts.astro index cdd5343..820cc16 100644 --- a/src/layouts/TagPosts.astro +++ b/src/layouts/TagPosts.astro @@ -6,13 +6,15 @@ import Header from "@components/Header.astro"; import Footer from "@components/Footer.astro"; import Card from "@components/Card"; import Pagination from "@components/Pagination.astro"; -import { SITE } from "@config"; +import { SITE, markketplace } from "@config"; import { getCollection } from "astro:content"; import type Store from "../interfaces/Store"; import { slugifyStr } from "@utils/slugify"; const stores = await getCollection("stores"); -const store = stores?.[0]?.data as unknown as Store; +const store = stores?.find( + (store: { data: Store }) => store.data.slug === markketplace.STORE_SLUG +)?.data; export interface Props { currentPage: number; @@ -22,7 +24,13 @@ export interface Props { tagName: string; } -const { currentPage, totalPages, paginatedPosts, tag, tagName } = Astro.props; +const { + currentPage, + totalPages, + paginatedPosts, + tag = "all", + tagName, +} = Astro.props; --- @@ -38,9 +46,9 @@ const { currentPage, totalPages, paginatedPosts, tag, tagName } = Astro.props; paginatedPosts.map(({ data, id }) => ( tag.Label)} frontmatter={{ author: "x", - tags: data.Tags.map(tag => tag.Label), title: data.Title, pubDatetime: new Date(data.createdAt), modDatetime: new Date(data.updatedAt), diff --git a/src/pages/search.astro b/src/pages/search.astro index 5f6d151..9a206ca 100644 --- a/src/pages/search.astro +++ b/src/pages/search.astro @@ -29,5 +29,5 @@ const searchList = posts.map(({ data, id }) => ({
-