From b21c39aaf41f0fd2376bdf5f832d32a8ebbaa95a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 31 Jan 2024 22:02:43 -0500 Subject: OSFT Archive Page; Blog improvements --- src/pages/blog/[...slug].astro | 8 ++++++++ src/pages/blog/tags/[tag].astro | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/pages/blog') diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index de4efb6..8713ab5 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -18,6 +18,14 @@ const { Content } = await entry.render(); ---
+ ← All articles
+ diff --git a/src/pages/blog/tags/[tag].astro b/src/pages/blog/tags/[tag].astro index 8885cfa..a43f13f 100644 --- a/src/pages/blog/tags/[tag].astro +++ b/src/pages/blog/tags/[tag].astro @@ -3,7 +3,11 @@ import Page from '../../../layouts/Page.astro'; export async function getStaticPaths() { const allPosts = await Astro.glob('../../../content/blog/*.md'); - const uniqueTags = [...new Set(allPosts.map((post) => post.frontmatter.tags).flat())]; + let uniqueTags = []; + + if (allPosts) { + uniqueTags = [...new Set(allPosts.map((post) => post.frontmatter.tags).flat())]; + } return uniqueTags.map((tag) => { const filteredPosts = allPosts.filter((post) => post.frontmatter.tags.includes(tag)); @@ -18,11 +22,12 @@ const { tag } = Astro.params; const { posts } = Astro.props; --- - {posts.map((post) => { + {console.log(posts)} + {posts && posts.map((post) => { return ( -
- {post.frontmatter.title} -
+
+ {post.frontmatter.title} +
) })}
-- cgit v1.2.3