2023-09-26 14:27:38 +08:00
|
|
|
---
|
|
|
|
import {formatDateToYYYYMMDD} from "../utils/date-utils";
|
|
|
|
import { Icon } from 'astro-icon/components';
|
2023-10-06 02:53:47 +08:00
|
|
|
import {i18n} from "../i18n/translation";
|
|
|
|
import I18nKey from "../i18n/i18nKey";
|
2023-09-26 14:27:38 +08:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
class: string;
|
2023-10-18 17:31:11 +08:00
|
|
|
published: Date;
|
2023-09-26 14:27:38 +08:00
|
|
|
tags: string[];
|
2023-11-07 12:35:52 +08:00
|
|
|
category: string;
|
2024-01-22 02:06:24 +08:00
|
|
|
hideTagsForMobile: boolean;
|
2023-09-26 14:27:38 +08:00
|
|
|
}
|
2024-01-22 02:06:24 +08:00
|
|
|
const {published, tags, category, hideTagsForMobile} = Astro.props;
|
2023-09-26 14:27:38 +08:00
|
|
|
const className = Astro.props.class;
|
|
|
|
---
|
|
|
|
|
2023-10-16 22:45:30 +08:00
|
|
|
<div class:list={["flex flex-wrap text-neutral-500 dark:text-neutral-400 items-center gap-4 gap-x-4 gap-y-2", className]}>
|
2023-09-26 14:27:38 +08:00
|
|
|
<!-- publish date -->
|
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="meta-icon"
|
|
|
|
>
|
|
|
|
<Icon name="material-symbols:calendar-today-outline-rounded" class="text-xl"></Icon>
|
|
|
|
</div>
|
2023-10-18 17:31:11 +08:00
|
|
|
<span class="text-black/50 dark:text-white/50 text-sm font-medium">{formatDateToYYYYMMDD(published)}</span>
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
|
|
|
|
2024-01-22 02:06:24 +08:00
|
|
|
<!-- categories -->
|
2023-09-26 14:27:38 +08:00
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="meta-icon"
|
|
|
|
>
|
|
|
|
<Icon name="material-symbols:menu-rounded" class="text-xl"></Icon>
|
|
|
|
</div>
|
2023-10-18 01:25:31 +08:00
|
|
|
<div class="flex flex-row flex-nowrap">
|
2024-01-21 20:21:04 +08:00
|
|
|
<div><a href=`/archive/category/${category || 'uncategorized'}` aria-label=`View all posts in the ${category} category`
|
|
|
|
class="link-lg transition text-black/50 dark:text-white/50 text-sm font-medium
|
|
|
|
hover:text-[var(--primary)] dark:hover:text-[var(--primary)] whitespace-nowrap">
|
|
|
|
{category || i18n(I18nKey.uncategorized)}
|
|
|
|
</a></div>
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- tags -->
|
2024-01-22 02:06:24 +08:00
|
|
|
<div class:list={["items-center", {"flex": !hideTagsForMobile, "hidden md:flex": hideTagsForMobile}]}>
|
2023-09-26 14:27:38 +08:00
|
|
|
<div class="meta-icon"
|
|
|
|
>
|
|
|
|
<Icon name="material-symbols:tag-rounded" class="text-xl"></Icon>
|
|
|
|
</div>
|
2023-10-18 01:25:31 +08:00
|
|
|
<div class="flex flex-row flex-nowrap">
|
2023-10-18 17:31:11 +08:00
|
|
|
{(tags && tags.length > 0) && tags.map(tag => <div
|
2023-09-26 14:27:38 +08:00
|
|
|
class="with-divider"
|
|
|
|
>
|
2023-10-20 11:36:55 +08:00
|
|
|
<a href=`/archive/tag/${tag}` aria-label=`View all posts with the ${tag} tag`
|
2023-11-08 10:36:59 +08:00
|
|
|
class="link-lg transition text-black/50 dark:text-white/50 text-sm font-medium
|
2023-10-18 01:25:31 +08:00
|
|
|
hover:text-[var(--primary)] dark:hover:text-[var(--primary)] whitespace-nowrap">
|
2023-09-26 14:27:38 +08:00
|
|
|
{tag}
|
|
|
|
</a>
|
|
|
|
</div>)}
|
2023-10-18 17:31:11 +08:00
|
|
|
{!(tags && tags.length > 0) && <div class="transition text-black/50 dark:text-white/50 text-sm font-medium">{i18n(I18nKey.noTags)}</div>}
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
@tailwind components;
|
|
|
|
|
|
|
|
@layer components {
|
|
|
|
.meta-icon {
|
|
|
|
@apply w-8 h-8 transition rounded-md flex items-center justify-center bg-[var(--btn-regular-bg)]
|
2023-10-02 01:52:08 +08:00
|
|
|
text-[var(--btn-content)] mr-2
|
2023-09-26 14:27:38 +08:00
|
|
|
}
|
|
|
|
.with-divider {
|
2024-01-22 11:25:56 +08:00
|
|
|
@apply before:content-['/'] before:ml-1.5 before:mr-0.5 before:text-[var(--meta-divider)] before:text-sm
|
2023-09-26 14:27:38 +08:00
|
|
|
before:font-medium before:first-of-type:hidden before:transition
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|