diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2024-01-31 22:02:43 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2024-01-31 22:02:43 -0500 |
| commit | b21c39aaf41f0fd2376bdf5f832d32a8ebbaa95a (patch) | |
| tree | 99e7b6853deebfdf1de41905ddd2ecd931527833 /src/pages/blog | |
| parent | 126e0c277881b16675d43b663ce8d95b51e93ea4 (diff) | |
| download | personal-website-b21c39aaf41f0fd2376bdf5f832d32a8ebbaa95a.tar.gz personal-website-b21c39aaf41f0fd2376bdf5f832d32a8ebbaa95a.tar.bz2 personal-website-b21c39aaf41f0fd2376bdf5f832d32a8ebbaa95a.zip | |
OSFT Archive Page; Blog improvements
Diffstat (limited to 'src/pages/blog')
| -rw-r--r-- | src/pages/blog/[...slug].astro | 8 | ||||
| -rw-r--r-- | src/pages/blog/tags/[tag].astro | 15 |
2 files changed, 18 insertions, 5 deletions
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(); --- <Page title={entry.data.title} description={entry.data.description} date={formatDate(entry.data.date)}> <main> + <a href="/blog" class="back-link">← All articles</a> <Content /> </main> </Page> +<style> + main { + background-color: #3B513B; + padding: 1.2em; + border-radius: 20px; + } +</style> 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; --- <Page title={tag}> - {posts.map((post) => { + {console.log(posts)} + {posts && posts.map((post) => { return ( - <div> - <a href={post.url}>{post.frontmatter.title}</a> - </div> + <div> + <a href={post.url}>{post.frontmatter.title}</a> + </div> ) })} </Page> |
