website/src/components/SmallCard.astro

49 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-04-03 14:27:48 +02:00
---
import markdownToText from "@helpers/markdownToText";
2024-04-03 21:09:50 +02:00
import { useTranslatedPath } from "@i18n/utils";
const tp = useTranslatedPath(Astro.url);
2024-04-03 14:27:48 +02:00
interface Props {
post: {
data: {
title: string;
2024-04-03 18:07:54 +02:00
description?: string;
icon?: string;
tags?: string[];
2024-04-03 14:27:48 +02:00
};
collection: string;
body: string;
slug: string;
};
}
const { post } = Astro.props;
---
<a
2024-04-03 21:09:50 +02:00
href={tp(`/${post.collection}/${post.slug.split("/")[0]}`)}
2024-04-03 14:27:48 +02:00
class="rounded-diag-md border border-neutral p-4 overflow-hidden"
>
<h2
class="text-2xl flex gap-2 items-center line-clamp text-ellipsis overflow-hidden"
>
{post.data.icon && <img src={post.data.icon} class="h-6" />}
{post.data.title}
</h2>
<p class="text-ellipsis overflow-hidden line-clamp-2">
{post.data.description || markdownToText(post.body).slice(0, 200)}
</p>
{
post.data.tags && (
<div class="flex gap-2 mt-2">
{post.data.tags.map((tag) => (
<span class="text-xs border border-neutral p-2 rounded-md">
{tag}
</span>
))}
</div>
)
}
</a>