From d70327ffb9e57fa65bb2d4195c26b0cb663a10a8 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Tue, 24 Oct 2023 14:00:40 -0500 Subject: [PATCH] tags on home page --- src/components/PostList.astro | 38 +++++++++++++++++++++------------ src/components/TagList.astro | 18 ++++++++++++++++ src/pages/posts/[...slug].astro | 10 ++------- src/styles/_colors.scss | 3 ++- src/styles/post.scss | 27 ----------------------- src/styles/tagList.scss | 27 +++++++++++++++++++++++ 6 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 src/components/TagList.astro create mode 100644 src/styles/tagList.scss diff --git a/src/components/PostList.astro b/src/components/PostList.astro index 1e838a7..33ce2eb 100644 --- a/src/components/PostList.astro +++ b/src/components/PostList.astro @@ -2,6 +2,7 @@ import { getCollection, type CollectionEntry } from "astro:content"; import Timestamp from "./Timestamp.astro"; import { sortBy } from "lodash-es"; +import TagList from "./TagList.astro"; interface Props { basePath: string; @@ -43,18 +44,22 @@ const sortedPosts = sortBy(allPosts, (post) => -post.data.date); { sortedPosts.map((post) => { return ( - - - - - - - - {post.data.title} - - - - + <> + + + + + + + + + + + ); }) } @@ -63,14 +68,14 @@ const sortedPosts = sortBy(allPosts, (post) => -post.data.date); diff --git a/src/components/TagList.astro b/src/components/TagList.astro new file mode 100644 index 0000000..2702f48 --- /dev/null +++ b/src/components/TagList.astro @@ -0,0 +1,18 @@ +--- +import "../styles/tagList.scss"; + +const { extraFront, tags, extraBack } = Astro.props; +--- + +
+ {extraFront} + { + tags.toSorted().map((tag) => ( + +