feat: add tags index page

This commit is contained in:
Ruidy 2025-01-01 02:46:16 +01:00
parent f06ae6b055
commit 65c976ed93
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 74 additions and 0 deletions

View file

@ -2,4 +2,5 @@
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/blog">Blog</a>
<a href="/tags">Tags</a>
</nav>

View file

@ -8,5 +8,34 @@ const { frontmatter } = Astro.props;
<p><em>{frontmatter.description}</em></p>
<p>Written by: {frontmatter.author}</p>
<img src={frontmatter.image.url} alt={frontmatter.image.alt} width="500" />
<div class="tags">
{
frontmatter.tags.map((tag: any) => (
<p class="tag">
<a href={`/tags/${tag}`}>{tag}</a>
</p>
))
}
</div>
<slot />
</BaseLayout>
<style>
a {
color: #00539f;
}
.tags {
display: flex;
flex-wrap: wrap;
}
.tag {
margin: 0.25em;
border: dotted 1px #a1a1a1;
border-radius: 0.5em;
padding: 0.5em 1em;
font-size: 1.15em;
background-color: #f8fcfd;
}
</style>

View file

@ -0,0 +1,44 @@
---
import BaseLayout from "../../layouts/BaseLayout.astro";
const tags = [
...new Set(
Object.values(import.meta.glob("../posts/*.md", { eager: true })).flatMap(
(post: any) => post.frontmatter.tags,
),
),
];
---
<BaseLayout pageTitle="Tags">
<p>This is a list of all tags.</p>
<div class="tags">
{
tags.map((tag: any) => (
<p class="tag">
<a href={`/tags/${tag}`}>{tag}</a>
</p>
))
}
</div>
</BaseLayout>
<style>
a {
color: #00539f;
}
.tags {
display: flex;
flex-wrap: wrap;
}
.tag {
margin: 0.25em;
border: dotted 1px #a1a1a1;
border-radius: 0.5em;
padding: 0.5em 1em;
font-size: 1.15em;
background-color: #f8fcfd;
}
</style>