/
PostTags.astro
54 lines (46 loc) · 945 Bytes
/
PostTags.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
import type { StarlightBlogEntry } from '../libs/content'
import { getBlogPathWithBase } from '../libs/page'
import { getEntryTags } from '../libs/tags'
interface Props {
entry: StarlightBlogEntry
}
const { entry } = Astro.props
const tags = getEntryTags(entry)
---
{
tags.length > 0 ? (
<div>
<b>Tags: </b>
<ul>
{tags.map((tag) => (
<li>
<a href={getBlogPathWithBase(`/tags/${tag.slug}`)}>{tag.label}</a>
</li>
))}
</ul>
</div>
) : null
}
<style>
ul {
display: inline;
padding: 0;
}
li {
display: inline-block;
margin-bottom: 0.25rem;
padding: 0;
}
a {
border: 1px solid var(--sl-color-gray-5);
border-radius: 0.3rem;
font-size: var(--sl-text-sm);
margin-inline: 0.2rem;
padding: 0.25rem 0.5rem 0.35rem;
text-decoration: none;
}
a:hover {
border-color: var(--sl-color-gray-2);
}
</style>