From 5916113815600379e346367aea29c45d65133336 Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Sun, 26 Feb 2023 00:38:59 +0700 Subject: [PATCH 1/2] fix(style): update style for .badge-default --- src/assets/scss/_styles.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/assets/scss/_styles.scss b/src/assets/scss/_styles.scss index 004d79d2..5c185f2a 100644 --- a/src/assets/scss/_styles.scss +++ b/src/assets/scss/_styles.scss @@ -13,8 +13,7 @@ a { } .badge-default { - @extend %badge; - @apply bg-style-primary text-style-primary-inverted; + @apply text-style-secondary border-b-2 border-dotted border-b-style-primary; } .badge-outline { From 0754c715c6ade4cb045b9235cd07e1876ac6c27f Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Sun, 26 Feb 2023 00:39:12 +0700 Subject: [PATCH 2/2] feat(page): add page /tags/{slug} --- src/pages/tags/[slug].astro | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/pages/tags/[slug].astro diff --git a/src/pages/tags/[slug].astro b/src/pages/tags/[slug].astro new file mode 100644 index 00000000..f68f0826 --- /dev/null +++ b/src/pages/tags/[slug].astro @@ -0,0 +1,55 @@ +--- +import { getCollection } from 'astro:content' +import kebabCase from 'lodash.kebabcase' + +import LeetCodeDifficulty from '@/components/LeetCodeDifficulty.astro' +import PostList from '@/components/post/PostList.astro' +import siteConfig from '@/configs/site' +import AppLayout from '@/layouts/AppLayout.astro' + +export async function getStaticPaths() { + const allTags = new Set() + const allPosts = await getCollection( + 'leetcode-solutions', + ({ data }) => data.tags?.length > 0 + ) + allPosts.forEach((post) => + post.data.tags?.forEach((t: string) => allTags.add(t)) + ) + + return Array.from(allTags).map((tag) => { + const slug = kebabCase(tag) + const filteredPosts = allPosts.filter((post) => + post.data.tags?.includes(tag) + ) + + return { + params: { slug }, + props: { + posts: filteredPosts, + tag, + }, + } + }) +} + +const { tag, posts } = Astro.props +const { title, description, author } = siteConfig +--- + + +
+
+

+ Posts by tag: + {tag} +

+
+ +
+