mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-28 16:48:00 +02:00
63 lines
1.4 KiB
Plaintext
63 lines
1.4 KiB
Plaintext
---
|
|
import LayoutBase from '@layouts/Base/index.astro'
|
|
import type { Page } from 'astro'
|
|
import type { CollectionEntry } from 'astro:content'
|
|
import PostTeaser from '@components/PostTeaser/index.astro'
|
|
import Pagination from '@components/Pagination/index.astro'
|
|
import PhotoTeaser from '@components/PhotoTeaser.astro'
|
|
import LinkTeaser from '@components/LinkTeaser/index.astro'
|
|
|
|
type Props = {
|
|
page: Page<CollectionEntry<'articles' | 'links' | 'photos'>>
|
|
title: string
|
|
pageTitle: string
|
|
}
|
|
|
|
const { page, title, pageTitle } = Astro.props
|
|
const classes = `posts ${
|
|
title && title !== '' && title.toLowerCase().includes('photos')
|
|
? 'photos'
|
|
: ''
|
|
}`
|
|
---
|
|
|
|
<style>
|
|
.photos {
|
|
display: grid;
|
|
gap: var(--spacer);
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
@media (min-width: 40rem) {
|
|
.photos {
|
|
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<LayoutBase title={title} pageTitle={pageTitle}>
|
|
<div class={classes}>
|
|
{
|
|
page?.data?.map((post) =>
|
|
post.collection === 'photos' ? (
|
|
<PhotoTeaser post={post} />
|
|
) : post.collection === 'links' ? (
|
|
<LinkTeaser post={post} />
|
|
) : (
|
|
<PostTeaser post={post} />
|
|
)
|
|
)
|
|
}
|
|
</div>
|
|
|
|
{
|
|
page.currentPage && (
|
|
<Pagination
|
|
currentPage={page.currentPage}
|
|
numPages={page.lastPage}
|
|
slug={`/${Astro.url.pathname.split('/')[1]}`}
|
|
/>
|
|
)
|
|
}
|
|
</LayoutBase>
|