diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index a7a7143..56ed8c0 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -1,12 +1,13 @@ --- -import type { CollectionEntry } from "astro:content"; import path from "node:path"; +import type { CollectionEntry } from "astro:content"; import { Icon } from "astro-icon/components"; import I18nKey from "../i18n/i18nKey"; import { i18n } from "../i18n/translation"; import { getDir } from "../utils/url-utils"; -import ImageWrapper from "./misc/ImageWrapper.astro"; import PostMetadata from "./PostMeta.astro"; +import ImageWrapper from "./misc/ImageWrapper.astro"; +import { umamiConfig } from "../config"; interface Props { class?: string; @@ -16,7 +17,7 @@ interface Props { published: Date; updated?: Date; tags: string[]; - category: string | null; + category: string; image: string; description: string; draft: boolean; @@ -34,6 +35,8 @@ const { description, style, } = Astro.props; + +const isPinned = entry.data.pinned === true; const className = Astro.props.class; const hasCover = image !== undefined && image !== null && image !== ""; @@ -51,6 +54,11 @@ const { remarkPluginFrontmatter } = await entry.render(); before:w-1 before:h-5 before:rounded-md before:bg-[var(--primary)] before:absolute before:top-[35px] before:left-[18px] before:hidden md:before:block "> + {isPinned && ( + + 置顶 + + )} {title} @@ -64,14 +72,14 @@ const { remarkPluginFrontmatter } = await entry.render(); { description || remarkPluginFrontmatter.excerpt } - +
-
- {remarkPluginFrontmatter.words} {" " + i18n(remarkPluginFrontmatter.words === 1 ? I18nKey.wordCount : I18nKey.wordsCount)} -
+
{remarkPluginFrontmatter.words} {" " + i18n(I18nKey.wordsCount)}
+
|
+
{remarkPluginFrontmatter.minutes} {" " + i18n(I18nKey.minutesCount)}
|
- {remarkPluginFrontmatter.minutes} {" " + i18n(remarkPluginFrontmatter.minutes === 1 ? I18nKey.minuteCount : I18nKey.minutesCount)} + 加载中...
@@ -83,6 +91,7 @@ const { remarkPluginFrontmatter } = await entry.render(); "md:w-[var(--coverWidth)] relative md:absolute md:top-3 md:bottom-3 md:right-3 rounded-xl overflow-hidden active:scale-95" ]} >
+
@@ -106,5 +115,67 @@ const { remarkPluginFrontmatter } = await entry.render();
+ + + \ No newline at end of file diff --git a/src/components/PostMeta.astro b/src/components/PostMeta.astro index 488e85e..2e8070e 100644 --- a/src/components/PostMeta.astro +++ b/src/components/PostMeta.astro @@ -2,17 +2,19 @@ import { Icon } from "astro-icon/components"; import I18nKey from "../i18n/i18nKey"; import { i18n } from "../i18n/translation"; +import { getDir, url } from "../utils/url-utils"; import { formatDateToYYYYMMDD } from "../utils/date-utils"; -import { getCategoryUrl, getTagUrl } from "../utils/url-utils"; +import { umamiConfig } from "../config"; interface Props { class: string; published: Date; updated?: Date; tags: string[]; - category: string | null; + category: string; hideTagsForMobile?: boolean; hideUpdateDate?: boolean; + slug?: string; } const { published, @@ -21,6 +23,7 @@ const { category, hideTagsForMobile = false, hideUpdateDate = false, + slug, } = Astro.props; const className = Astro.props.class; --- @@ -53,7 +56,7 @@ const className = Astro.props.class;
- {category || i18n(I18nKey.uncategorized)} @@ -70,13 +73,79 @@ const className = Astro.props.class;
{(tags && tags.length > 0) && tags.map((tag, i) => (
/
-
- {tag.trim()} + {tag} ))} {!(tags && tags.length > 0) &&
{i18n(I18nKey.noTags)}
}
- \ No newline at end of file + + + {slug && ( +
+
+ +
+ 加载中... +
+ )} + + +{slug && ( + +)} \ No newline at end of file