2023-09-26 14:27:38 +08:00
|
|
|
---
|
2023-12-28 14:37:18 +08:00
|
|
|
import path from "path";
|
2024-02-18 18:13:43 +08:00
|
|
|
import PostMetadata from "./PostMeta.astro";
|
|
|
|
import ImageWrapper from "./misc/ImageWrapper.astro";
|
|
|
|
import { Icon } from 'astro-icon/components';
|
|
|
|
import {i18n} from "../i18n/translation";
|
|
|
|
import I18nKey from "../i18n/i18nKey";
|
|
|
|
import {getDir} from "../utils/url-utils";
|
|
|
|
|
2023-09-26 14:27:38 +08:00
|
|
|
interface Props {
|
|
|
|
class: string;
|
|
|
|
entry: any;
|
|
|
|
title: string;
|
|
|
|
url: 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;
|
2023-10-21 10:52:01 +08:00
|
|
|
image: string;
|
2023-09-26 14:27:38 +08:00
|
|
|
description: string;
|
|
|
|
words: number;
|
2024-01-21 12:54:41 +08:00
|
|
|
draft: boolean;
|
2024-03-13 01:32:54 +08:00
|
|
|
style: string;
|
2023-09-26 14:27:38 +08:00
|
|
|
}
|
2024-03-13 01:32:54 +08:00
|
|
|
const { entry, title, url, published, tags, category, image, description, words, style } = Astro.props;
|
2023-09-26 14:27:38 +08:00
|
|
|
const className = Astro.props.class;
|
|
|
|
|
2023-10-21 10:52:01 +08:00
|
|
|
const hasCover = image !== undefined && image !== null && image !== '';
|
2023-09-26 14:27:38 +08:00
|
|
|
|
2023-10-06 03:02:46 +08:00
|
|
|
const coverWidth = "28%";
|
2023-09-26 14:27:38 +08:00
|
|
|
|
|
|
|
const { remarkPluginFrontmatter } = await entry.render();
|
|
|
|
|
|
|
|
---
|
2024-03-13 01:32:54 +08:00
|
|
|
<div class:list={["card-base flex flex-col-reverse md:flex-col w-full rounded-[var(--radius-large)] overflow-hidden relative", className]} style={style}>
|
2024-01-22 02:06:24 +08:00
|
|
|
<div class:list={["pl-6 md:pl-9 pr-6 md:pr-2 pt-6 md:pt-7 pb-6 relative", {"w-full md:w-[calc(100%_-_52px_-_12px)]": !hasCover, "w-full md:w-[calc(100%_-_var(--coverWidth)_-_12px)]": hasCover}]}>
|
2023-09-26 14:27:38 +08:00
|
|
|
<a href={url}
|
2024-02-18 18:13:43 +08:00
|
|
|
class="transition w-full block font-bold mb-3 text-3xl text-90
|
2023-09-26 14:27:38 +08:00
|
|
|
hover:text-[var(--primary)] dark:hover:text-[var(--primary)]
|
2023-10-23 17:45:07 +08:00
|
|
|
active:text-[var(--title-active)] dark:active:text-[var(--title-active)]
|
2023-09-26 14:27:38 +08:00
|
|
|
before:w-1 before:h-5 before:rounded-md before:bg-[var(--primary)]
|
2024-01-22 02:06:24 +08:00
|
|
|
before:absolute before:top-[35px] before:left-[18px] before:hidden md:before:block
|
2023-09-26 14:27:38 +08:00
|
|
|
">
|
2024-01-22 02:06:24 +08:00
|
|
|
{title}<Icon class="inline text-[var(--primary)] md:hidden -translate-y-[0.15rem]" name="material-symbols:chevron-right-rounded" size={28} ></Icon>
|
2023-09-26 14:27:38 +08:00
|
|
|
</a>
|
|
|
|
|
|
|
|
<!-- metadata -->
|
2024-01-22 02:06:24 +08:00
|
|
|
<PostMetadata published={published} tags={tags} category={category} hideTagsForMobile={true} class:list={{"mb-4": description, "mb-6": !description}}></PostMetadata>
|
2023-09-26 14:27:38 +08:00
|
|
|
|
2024-02-18 18:13:43 +08:00
|
|
|
<!-- description -->
|
|
|
|
<div class="transition text-75 mb-3.5">
|
2023-09-26 14:27:38 +08:00
|
|
|
{ description }
|
|
|
|
</div>
|
|
|
|
|
2024-02-18 18:13:43 +08:00
|
|
|
<!-- word count and read time -->
|
2023-09-26 14:27:38 +08:00
|
|
|
<div class="text-sm text-black/30 dark:text-white/30 flex gap-4 transition">
|
2023-10-06 02:53:47 +08:00
|
|
|
<div>{remarkPluginFrontmatter.words} {" " + i18n(I18nKey.wordsCount)}</div>
|
2023-09-26 14:27:38 +08:00
|
|
|
<div>|</div>
|
2023-10-06 02:53:47 +08:00
|
|
|
<div>{remarkPluginFrontmatter.minutes} {" " + i18n(I18nKey.minutesCount)}</div>
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2023-10-20 11:36:55 +08:00
|
|
|
{hasCover && <a href={url} aria-label={title}
|
2023-09-29 11:58:14 +08:00
|
|
|
class:list={["group",
|
2023-11-06 21:56:53 +08:00
|
|
|
"max-h-[20vh] md:max-h-none mx-4 mt-4 -mb-2 md:mb-0 md:mx-0 md:mt-0",
|
2023-10-16 22:45:30 +08:00
|
|
|
"md:w-[var(--coverWidth)] relative md:absolute md:top-3 md:bottom-3 md:right-3 rounded-xl overflow-hidden active:scale-95"
|
2023-09-29 11:58:14 +08:00
|
|
|
]} >
|
2023-10-23 17:45:07 +08:00
|
|
|
<div class="absolute pointer-events-none z-10 w-full h-full group-hover:bg-black/30 group-active:bg-black/50 transition"></div>
|
|
|
|
<div class="absolute pointer-events-none z-20 w-full h-full flex items-center justify-center ">
|
2023-09-26 14:27:38 +08:00
|
|
|
<Icon name="material-symbols:chevron-right-rounded"
|
2023-10-04 18:02:00 +08:00
|
|
|
class="transition opacity-0 group-hover:opacity-100 text-white text-5xl">
|
|
|
|
</Icon>
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
2024-02-18 18:13:43 +08:00
|
|
|
<ImageWrapper src={image} basePath={path.join("content/posts/", getDir(entry.id))} alt="Cover Image of the Post"
|
2023-09-26 14:27:38 +08:00
|
|
|
class="w-full h-full">
|
2024-02-18 18:13:43 +08:00
|
|
|
</ImageWrapper>
|
2023-09-26 14:27:38 +08:00
|
|
|
</a>}
|
2023-10-04 18:02:00 +08:00
|
|
|
|
|
|
|
{!hasCover &&
|
2024-02-18 18:13:43 +08:00
|
|
|
<a href={url} aria-label={title} class="hidden md:flex btn-regular w-[3.25rem]
|
|
|
|
absolute right-3 top-3 bottom-3 rounded-xl bg-[var(--enter-btn-bg)]
|
|
|
|
hover:bg-[var(--enter-btn-bg-hover)] active:bg-[var(--enter-btn-bg-active)] active:scale-95
|
|
|
|
">
|
|
|
|
<Icon name="material-symbols:chevron-right-rounded"
|
|
|
|
class="transition text-[var(--primary)] text-4xl mx-auto">
|
|
|
|
</Icon>
|
2023-10-04 18:02:00 +08:00
|
|
|
</a>
|
|
|
|
}
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
2024-01-22 02:06:24 +08:00
|
|
|
<div class="transition border-t-[1px] border-dashed mx-6 border-black/10 dark:border-white/[0.15] last:border-t-0 md:hidden"></div>
|
2023-09-26 14:27:38 +08:00
|
|
|
|
|
|
|
<style lang="stylus" define:vars={{coverWidth}}>
|
|
|
|
</style>
|