Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/components/Block/Card.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
---
import { env } from '@src/env.config';
import Logo from '@components/Block/LogoIcon.astro';
import { DateTime } from 'luxon';

interface Props {
icon?: string;
tag?: string;
date?: Date;
heading: string;
summary: string;
uri: string;
}

const { icon = null, tag = null, heading = null, summary = null, uri = '/' } = Astro.props;
const {
icon = null,
tag = null,
date = null,
heading = null,
summary = null,
uri = '/',
} = Astro.props;
---

<x-card class="card">
Expand Down Expand Up @@ -41,6 +50,13 @@ const { icon = null, tag = null, heading = null, summary = null, uri = '/' } = A
{heading}
</a>
</h2>
{
date && date instanceof Date && (
<p class="card-date">
{DateTime.fromISO(date.toISOString(), { locale: 'en-GB' }).toFormat('d LLL, yyyy')}
</p>
)
}
<p>{summary}</p>
</div>
</x-card>
Expand Down Expand Up @@ -85,6 +101,11 @@ const { icon = null, tag = null, heading = null, summary = null, uri = '/' } = A
}
}

.card-date {
margin-top: calc(var(--space-3) * -0.75);
margin-bottom: calc(var(--space-3) * 0.75);
}

.card-preview {
position: relative;
overflow: hidden;
Expand Down
1 change: 1 addition & 0 deletions src/pages/blog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const featured = posts.shift();
heading={post.data.title}
summary={post.data.summary}
uri={`blog/${post.uid}`}
date={new Date(post.data.date) || null}
tag={post.tags[0]}
icon={post.tags[0]}
/>
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/blog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe('Blog page', () => {
const datetime = await time.getAttribute('datetime');
expect(isNaN(Date.parse((datetime || '').toString()))).toBe(false);

const summary = first.locator('p');
const summary = first.locator('p:not(.card-date)');
await expect(summary).toBeVisible();
expect((await summary.textContent())?.length ?? 0).toBeGreaterThan(20);
});
Expand Down