diff options
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> |
