feat: add pinned icon for post list

This commit is contained in:
radishzzz 2025-04-02 22:31:36 +01:00
parent 5cf09194d8
commit 594172c183
9 changed files with 165 additions and 145 deletions

View file

@ -11,12 +11,13 @@ type Post = CollectionEntry<'posts'> & {
}
}
const { posts, lang } = Astro.props
const { posts, lang, pinned = false } = Astro.props
const isTag = isTagPage(Astro.url.pathname)
export interface Props {
posts: Post[]
lang?: string
pinned?: boolean
}
function getPostPath(post: Post) {
@ -45,6 +46,19 @@ function getPostPath(post: Post) {
>
{post.data.title}
</a>
{/* pinned icon */}
{pinned && (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
aria-hidden="true"
class="ml-1 inline-block aspect-square w-3.7 shrink-0 translate-y--0.45 lg:(ml-2 w-4 translate-y--0.55)"
fill="currentColor"
>
<path d="M16.5 23.6c.6-6.1 1.1-8.6 7.2-15.5L15.9.4C9 6.5 6.5 7 .4 7.5l7.4 7.4-6.4 7 .7.7 7-6.4zm-.8-21.3 6 6c-5 6.1-5.7 8.1-6.2 12.2L3.4 8.5C7.5 8 9.5 7.3 15.6 2.3Z" />
</svg>
)}
</h3>
{/* mobile post time */}

View file

@ -39,7 +39,7 @@ const postsByYear = await getPostsByYear(lang)
{pinnedPosts.length > 0 && (
<section class="mb-7.5">
<div class="uno-decorative-line"></div>
<PostList posts={pinnedPosts} lang={lang} />
<PostList posts={pinnedPosts} lang={lang} pinned={true} />
</section>
)}