-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
import { Image } from 'astro:assets'; | ||
import Link from '@/components/Link.astro'; | ||
import PostMeta from '@/components/PostMeta.astro'; | ||
import TagList from '@/components/TagList.astro'; | ||
import { ROUTES } from '@/constants/routes'; | ||
import { cn } from '@/utils/styles'; | ||
import type { Post } from '@/types/post'; | ||
export interface Props { | ||
post: Post; | ||
} | ||
const { post } = Astro.props; | ||
const { data, slug, readingTime } = post; | ||
const { | ||
draft, | ||
publishDate, | ||
title, | ||
heroImage, | ||
heroAlt, | ||
// category, | ||
tags = [], | ||
description, | ||
} = data; | ||
const postMetaProps = { readingTime, publishDate }; | ||
--- | ||
|
||
{/* Text in right column determines height, 2 lines title + 2 lines description. */} | ||
{/* Image determines max-height. For cases when image isn't 16/9 so it's cropped. */} | ||
{/* Image for 2 + 2 lines text has 168px naturaly, limit to 172, h-44 = 176 */} | ||
|
||
<article | ||
class={cn( | ||
'w-full flex flex-col md:flex-row gap-4 lg:gap-6', | ||
'not-first:pt-4 not-last:pb-4 md:not-first:pt-6 md:not-last:pb-6', | ||
'not-last:border-b border-base-300' | ||
)} | ||
> | ||
{/* left column */} | ||
{ | ||
heroImage && ( | ||
<div class="md:basis-1/3 md:shrink-0"> | ||
<Image | ||
src={heroImage} | ||
alt={heroAlt} | ||
widths={[320, 540]} | ||
sizes="(max-width: 475px) 320px, 540px" | ||
itemprop="image" | ||
class="w-full h-40 md:h-full md:max-h-[172px] object-cover rounded-box" | ||
transition:name={`hero-${heroImage.src}`} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
{/* right column */} | ||
<div class="flex flex-col md:basis-2/3 md:shrink"> | ||
<PostMeta {...postMetaProps} class="text-sm text-captions leading-none mb-1" /> | ||
|
||
{/* title */} | ||
<h2 class="text-2xl font-bold break-words md:line-clamp-2 mt-0 mb-2"> | ||
<Link href={`${ROUTES.BLOG}${slug}`} variant="link-heading"> | ||
{title} | ||
{draft && <sup class="text-sm text-red-400">(draft)</sup>} | ||
</Link> | ||
</h2> | ||
|
||
{description && <p class="text-base mb-1 line-clamp-2">{description}</p>} | ||
|
||
<TagList tags={tags} class="mt-auto" /> | ||
</div> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters