src/components/blog/Hero.astro 1.5 K raw
1
---
2
import { getFormattedDate } from "@/utils";
3
import type { CollectionEntry } from "astro:content";
4
5
interface Props {
6
	content: CollectionEntry<"post">;
7
}
8
9
const { content } = Astro.props;
10
11
const datetime = content.data.publishDate.toISOString();
12
const postDate = getFormattedDate(content.data.publishDate);
13
---
14
15
<h1 class="title mb-3 sm:mb-1">{content.data.title}</h1>
16
<time datetime={datetime}>{postDate}</time>
17
{
18
	!!content.data.tags?.length && (
19
		<div class="mt-1 sm:mt-0 sm:inline sm:before:content-['|']">
20
			<svg
21
				aria-hidden="true"
22
				focusable="false"
23
				xmlns="http://www.w3.org/2000/svg"
24
				class="inline-block h-6 w-6"
25
				viewBox="0 0 24 24"
26
				stroke-width="1.5"
27
				stroke="currentColor"
28
				fill="none"
29
				stroke-linecap="round"
30
				stroke-linejoin="round"
31
			>
32
				<path stroke="none" d="M0 0h24v24H0z" fill="none" />
33
				<path d="M7.859 6h-2.834a2.025 2.025 0 0 0 -2.025 2.025v2.834c0 .537 .213 1.052 .593 1.432l6.116 6.116a2.025 2.025 0 0 0 2.864 0l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-6.117 -6.116a2.025 2.025 0 0 0 -1.431 -.593z" />
34
				<path d="M17.573 18.407l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-7.117 -7.116" />
35
				<path d="M6 9h-.01" />
36
			</svg>
37
			{content.data.tags.map((tag, i) => (
38
				<>
39
					<a
40
						class="cactus-link inline-block before:content-['#']"
41
						aria-label={`View more blogs with the tag ${tag}`}
42
						href={`/tags/${tag}`}
43
					>
44
						{tag}
45
					</a>
46
					{i < content.data.tags.length - 1 && ", "}
47
				</>
48
			))}
49
		</div>
50
	)
51
}
52
<p class="mt-8">{content.data.description}</p>