Merge pull request #176 from ladunjexa/patch-2
🎨 [enhancement] Added optional title functionality to Tags.astro
This commit is contained in:
@ -7,13 +7,19 @@ import type { Post } from '~/types';
|
||||
export interface Props {
|
||||
tags: Post['tags'];
|
||||
class?: string;
|
||||
title?: string | undefined;
|
||||
isCategory?: boolean;
|
||||
}
|
||||
|
||||
const { tags, class: className = 'text-sm' } = Astro.props;
|
||||
const { tags, class: className = 'text-sm', title = undefined, isCategory = false } = Astro.props;
|
||||
---
|
||||
|
||||
{
|
||||
tags && Array.isArray(tags) && (
|
||||
<>
|
||||
<>
|
||||
{title !== undefined && <span class="align-super font-normal underline underline-offset-4 decoration-2 dark:text-slate-400">{title}</span>}
|
||||
</>
|
||||
<ul class={className}>
|
||||
{tags.map((tag) => (
|
||||
<li class="bg-gray-100 dark:bg-slate-700 inline-block mr-2 mb-2 py-0.5 px-2 lowercase font-medium">
|
||||
@ -21,7 +27,7 @@ const { tags, class: className = 'text-sm' } = Astro.props;
|
||||
tag
|
||||
) : (
|
||||
<a
|
||||
href={getPermalink(tag, 'tag')}
|
||||
href={getPermalink(tag, (isCategory ? 'category' : 'tag')}
|
||||
class="text-muted dark:text-slate-300 hover:text-primary dark:hover:text-gray-200"
|
||||
>
|
||||
{tag}
|
||||
@ -30,5 +36,6 @@ const { tags, class: className = 'text-sm' } = Astro.props;
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user