Skip to content

Commit

Permalink
fix: use tag name for display in tags page (#438)
Browse files Browse the repository at this point in the history
Instead of slugified tags, original tag names will
be used for displaying tag names in the tags page.
  • Loading branch information
zhaozigu authored and satnaing committed Feb 8, 2025
1 parent 26020bb commit a56b28b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/components/Tag.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
export interface Props {
tag: string;
tagName: string;
size?: "sm" | "lg";
}
const { tag, size = "sm" } = Astro.props;
const { tag, tagName, size = "sm" } = Astro.props;
---

<li
Expand All @@ -24,7 +25,7 @@ const { tag, size = "sm" } = Astro.props;
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"
></path>
</svg>
&nbsp;<span>{tag}</span>
&nbsp;<span>{tagName}</span>
</a>
</li>

Expand Down
18 changes: 8 additions & 10 deletions src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ const nextPost =
</button>
</div>
<main id="main-content">
<h1 transition:name={slugifyStr(title)} class="post-title inline-block">{title}</h1>
<h1 transition:name={slugifyStr(title)} class="post-title inline-block">
{title}
</h1>
<Datetime
pubDatetime={pubDatetime}
modDatetime={modDatetime}
Expand All @@ -91,7 +93,7 @@ const nextPost =
</article>

<ul class="my-8">
{tags.map(tag => <Tag tag={slugifyStr(tag)} />)}
{tags.map(tag => <Tag tag={slugifyStr(tag)} tagName={tag} />)}
</ul>

<div
Expand Down Expand Up @@ -134,10 +136,8 @@ const nextPost =
stroke-linejoin="round"
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-left flex-none"
>
<>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M15 6l-6 6l6 6" />
</>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M15 6l-6 6l6 6" />
</svg>
<div>
<span>Previous Post</span>
Expand Down Expand Up @@ -168,10 +168,8 @@ const nextPost =
stroke-linejoin="round"
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right flex-none"
>
<>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M9 6l6 6l-6 6" />
</>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M9 6l6 6l-6 6" />
</svg>
</a>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tags/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let tags = getUniqueTags(posts);
<Header activeNav="tags" />
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
<ul>
{tags.map(({ tag }) => <Tag {tag} size="lg" />)}
{tags.map(({ tag, tagName }) => <Tag {tag} {tagName} size="lg" />)}
</ul>
</Main>
<Footer />
Expand Down

0 comments on commit a56b28b

Please sign in to comment.