Skip to content

Commit a56b28b

Browse files
zhaozigusatnaing
authored andcommitted
fix: use tag name for display in tags page (#438)
Instead of slugified tags, original tag names will be used for displaying tag names in the tags page.
1 parent 26020bb commit a56b28b

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/components/Tag.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
export interface Props {
33
tag: string;
4+
tagName: string;
45
size?: "sm" | "lg";
56
}
67
7-
const { tag, size = "sm" } = Astro.props;
8+
const { tag, tagName, size = "sm" } = Astro.props;
89
---
910

1011
<li
@@ -24,7 +25,7 @@ const { tag, size = "sm" } = Astro.props;
2425
d="M16.018 3.815 15.232 8h-4.966l.716-3.815-1.964-.37L8.232 8H4v2h3.857l-.751 4H3v2h3.731l-.714 3.805 1.965.369L8.766 16h4.966l-.714 3.805 1.965.369.783-4.174H20v-2h-3.859l.751-4H21V8h-3.733l.716-3.815-1.965-.37zM14.106 14H9.141l.751-4h4.966l-.752 4z"
2526
></path>
2627
</svg>
27-
&nbsp;<span>{tag}</span>
28+
&nbsp;<span>{tagName}</span>
2829
</a>
2930
</li>
3031

src/layouts/PostDetails.astro

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ const nextPost =
7777
</button>
7878
</div>
7979
<main id="main-content">
80-
<h1 transition:name={slugifyStr(title)} class="post-title inline-block">{title}</h1>
80+
<h1 transition:name={slugifyStr(title)} class="post-title inline-block">
81+
{title}
82+
</h1>
8183
<Datetime
8284
pubDatetime={pubDatetime}
8385
modDatetime={modDatetime}
@@ -91,7 +93,7 @@ const nextPost =
9193
</article>
9294

9395
<ul class="my-8">
94-
{tags.map(tag => <Tag tag={slugifyStr(tag)} />)}
96+
{tags.map(tag => <Tag tag={slugifyStr(tag)} tagName={tag} />)}
9597
</ul>
9698

9799
<div
@@ -134,10 +136,8 @@ const nextPost =
134136
stroke-linejoin="round"
135137
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-left flex-none"
136138
>
137-
<>
138-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
139-
<path d="M15 6l-6 6l6 6" />
140-
</>
139+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
140+
<path d="M15 6l-6 6l6 6" />
141141
</svg>
142142
<div>
143143
<span>Previous Post</span>
@@ -168,10 +168,8 @@ const nextPost =
168168
stroke-linejoin="round"
169169
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right flex-none"
170170
>
171-
<>
172-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
173-
<path d="M9 6l6 6l-6 6" />
174-
</>
171+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
172+
<path d="M9 6l6 6l-6 6" />
175173
</svg>
176174
</a>
177175
)

src/pages/tags/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let tags = getUniqueTags(posts);
1717
<Header activeNav="tags" />
1818
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
1919
<ul>
20-
{tags.map(({ tag }) => <Tag {tag} size="lg" />)}
20+
{tags.map(({ tag, tagName }) => <Tag {tag} {tagName} size="lg" />)}
2121
</ul>
2222
</Main>
2323
<Footer />

0 commit comments

Comments
 (0)