---
import { Icon } from "astro-icon/components";
import { commentConfig } from "@/config";
import I18nKey from "@/i18n/i18nKey";
import { i18n } from "@/i18n/translation";
import { formatDateToYYYYMMDD } from "@/utils/date-utils";
import { getCategoryUrl, getTagUrl } from "@/utils/url-utils";
export interface Props {
published: Date;
updated?: Date;
category?: string;
tags?: string[];
hideUpdateDate?: boolean;
hideTagsForMobile?: boolean;
isHome?: boolean;
className?: string;
id?: string;
words?: number;
minutes?: number;
showWordCount?: boolean; // 是否显示字数统计,默认false显示标签
customPath?: string;
pinned?: boolean;
}
const {
published,
updated,
category,
tags,
hideUpdateDate,
hideTagsForMobile,
isHome,
className = "",
id,
words,
minutes,
showWordCount = false,
customPath,
pinned,
} = Astro.props;
const path = customPath || (id ? `/posts/${id}` : "");
---
{
pinned && (
{i18n(I18nKey.pinned)}
)
}
{formatDateToYYYYMMDD(published)}
{
!hideUpdateDate && updated && updated.getTime() !== published.getTime() && (
{formatDateToYYYYMMDD(updated)}
)
}
{
showWordCount && words !== undefined && minutes !== undefined && (
<>
{words}
{" " + i18n(words === 1 ? I18nKey.wordCount : I18nKey.wordsCount)}
{/*
{minutes}
{" " +
i18n(minutes === 1 ? I18nKey.minuteCount : I18nKey.minutesCount)}
*/}
>
)
}
{
!showWordCount && (
{(tags && tags.length > 0) && tags.map((tag, i) => (
/
{tag.trim()}
))}
{!(tags && tags.length > 0) &&
{i18n(I18nKey.noTags)}
}
)
}
{
!isHome &&
commentConfig.type === 'twikoo' &&
commentConfig.twikoo?.visitorCount &&
id && (
{i18n(I18nKey.pageViews)}
{i18n(I18nKey.pageViewsLoading)}
)
}
{
!isHome &&
commentConfig.type === 'waline' &&
commentConfig.waline?.visitorCount &&
id && (
{i18n(I18nKey.pageViews)}
{i18n(I18nKey.pageViewsLoading)}
)
}
{
!isHome &&
commentConfig.type === 'artalk' &&
commentConfig.waline?.visitorCount &&
id && (
{i18n(I18nKey.pageViews)}
{i18n(I18nKey.pageViewsLoading)}
)
}