2023-09-26 14:27:38 +08:00
|
|
|
---
|
|
|
|
import PostMetadata from "./PostMetadata.astro";
|
|
|
|
interface Props {
|
|
|
|
class: string;
|
|
|
|
entry: any;
|
|
|
|
title: string;
|
|
|
|
url: string;
|
|
|
|
pubDate: Date;
|
|
|
|
tags: string[];
|
|
|
|
categories: string[];
|
|
|
|
cover: string;
|
|
|
|
description: string;
|
|
|
|
words: number;
|
|
|
|
}
|
|
|
|
const { entry, title, url, pubDate, tags, categories, cover, description, words } = Astro.props;
|
|
|
|
const className = Astro.props.class;
|
|
|
|
// console.log(Astro.props);
|
|
|
|
import ImageBox from "./misc/ImageBox.astro";
|
|
|
|
import ButtonTag from "./control/ButtonTag.astro";
|
|
|
|
import { Icon } from 'astro-icon/components';
|
2023-10-04 18:02:00 +08:00
|
|
|
import Button from "./control/Button.astro";
|
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
|
|
|
|
|
|
|
// tags = ['Foo', 'Bar', 'Baz', 'Qux', 'Quux'];
|
|
|
|
|
|
|
|
// const cover = 'https://saicaca.github.io/vivia-preview/assets/79905307_p0.jpg';
|
|
|
|
// cover = null;
|
|
|
|
const hasCover = cover !== undefined && cover !== null && cover !== '';
|
|
|
|
|
|
|
|
const coverWidth = "30%";
|
|
|
|
|
|
|
|
const { remarkPluginFrontmatter } = await entry.render();
|
|
|
|
|
|
|
|
---
|
2023-10-04 18:02:00 +08:00
|
|
|
<div class:list={["card-base flex flex-col-reverse md:flex-col w-full rounded-[var(--radius-large)] overflow-hidden relative", className]}>
|
|
|
|
<div class:list={[" px-10 pt-4 md:pt-7 pb-6 relative", {"w-full md:w-[calc(100%_-_52px)]": !hasCover, "w-full md:w-[calc(100%_-_var(--coverWidth))]": hasCover}]}>
|
2023-09-26 14:27:38 +08:00
|
|
|
<a href={url}
|
2023-10-04 18:02:00 +08:00
|
|
|
class="transition w-full block font-bold mb-3 text-3xl
|
2023-09-26 14:27:38 +08:00
|
|
|
text-black/90 dark:text-white/90
|
|
|
|
hover:text-[var(--primary)] dark:hover:text-[var(--primary)]
|
|
|
|
before:w-1 before:h-5 before:rounded-md before:bg-[var(--primary)]
|
2023-10-04 18:02:00 +08:00
|
|
|
before:absolute md:before:top-[35px] before:left-5
|
2023-09-26 14:27:38 +08:00
|
|
|
">
|
|
|
|
{title}
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<!-- metadata -->
|
2023-10-02 01:52:08 +08:00
|
|
|
<PostMetadata pubDate={pubDate} tags={tags} categories={categories} class:list={{"mb-4": description, "mb-6": !description}}></PostMetadata>
|
2023-09-26 14:27:38 +08:00
|
|
|
|
|
|
|
<div class="transition text-black/75 dark:text-white/75 mb-4">
|
|
|
|
{ description }
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
{hasCover && <a href={url}
|
2023-09-29 11:58:14 +08:00
|
|
|
class:list={["group",
|
2023-10-04 18:02:00 +08:00
|
|
|
"max-h-[20vh] md:max-h-none mx-4 mt-4 md:mx-0 md:mt-0",
|
|
|
|
"md:w-[var(--coverWidth)] relative md:absolute md:top-3 md:bottom-3 md:right-3 rounded-xl overflow-hidden"
|
2023-09-29 11:58:14 +08:00
|
|
|
]} >
|
2023-09-26 14:27:38 +08:00
|
|
|
<div class="absolute z-10 w-full h-full group-hover:bg-black/30 group-active:bg-black/50 transition"></div>
|
|
|
|
<div class="absolute z-20 w-full h-full flex items-center justify-center ">
|
|
|
|
<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>
|
2023-10-02 01:52:08 +08:00
|
|
|
<ImageBox src={cover}
|
2023-09-26 14:27:38 +08:00
|
|
|
class="w-full h-full">
|
|
|
|
</ImageBox>
|
|
|
|
</a>}
|
2023-10-04 18:02:00 +08:00
|
|
|
|
|
|
|
{!hasCover &&
|
|
|
|
<a href={url} class="hidden md:block">
|
|
|
|
<Button width="52px" height="full" class="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)]">
|
|
|
|
<Icon name="material-symbols:chevron-right-rounded"
|
|
|
|
class="transition text-[var(--primary)] text-4xl mx-auto">
|
|
|
|
</Icon>
|
|
|
|
</Button>
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
|
2023-09-26 14:27:38 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="stylus" define:vars={{coverWidth}}>
|
|
|
|
:root
|
|
|
|
--btn-enter-bg oklch(0.98 0.005 var(--hue))
|
|
|
|
--btn-enter-bg-dark oklch(0.2 0.02 var(--hue))
|
|
|
|
|
|
|
|
</style>
|