1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-28 08:37:57 +02:00
blog/src/components/PostTeaser/index.astro
Matthias Kretschmann 3b25ae2282
Location fetching (#843)
* location component

* fetching with @nanostores/query

* layouts reorg

* typescript plugins cleanup

* location component unit test cases

* fetch only when visible
2023-10-04 14:45:54 +01:00

39 lines
841 B
Plaintext

---
import PostTitle from '@layouts/Post/Title.astro'
import styles from './index.module.css'
import Picture from '@components/Picture/index.astro'
import type { CollectionEntry } from 'astro:content'
type Props = {
post: CollectionEntry<'articles' | 'links'>
hideDate?: boolean
}
const { post, hideDate } = Astro.props
const { slug } = post
const { title, date, updated } = post.data
const { image } = post.data as CollectionEntry<'articles'>['data']
---
<a class={styles.post} href={`/${slug}/`}>
{
image ? (
<Picture
class={styles.image}
src={image}
alt={`Teaser for ${title}`}
width={686}
height={200}
objectFit
/>
) : null
}
<PostTitle
title={title}
date={hideDate ? undefined : date}
updated={updated}
className={styles.title}
/>
</a>