Skip to content

Commit 008a472

Browse files
committed
feat: added post page
1 parent 8d574a5 commit 008a472

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/pages/writing/[...slug].astro

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
import Container from '@/components/Container.astro';
3+
import Avatar from '@/components/ui/Avatar.astro';
4+
import BaseLayout from '@/layouts/BaseLayout.astro';
5+
import { DEFAULT_CONFIGURATION } from '@/lib/constants';
6+
import { Image } from 'astro:assets';
7+
import { getCollection, render } from 'astro:content';
8+
9+
export async function getStaticPaths() {
10+
const entries = await getCollection('posts');
11+
12+
return entries.map((entry) => ({
13+
params: { slug: entry.id },
14+
props: { entry },
15+
}));
16+
}
17+
18+
const { entry } = Astro.props;
19+
const { Content } = await render(entry);
20+
---
21+
22+
<BaseLayout>
23+
<Container>
24+
<article class="flex flex-col gap-6">
25+
<div class="flex flex-col gap-2 pt-6">
26+
<a href="/writing" class="transition-all text-muted-foreground hover:text-foreground pb-4 text-sm">
27+
Back to writing
28+
</a>
29+
<div class="flex flex-col gap-1.5">
30+
<Avatar />
31+
<span class="text-foreground">{DEFAULT_CONFIGURATION.author.name}</span>
32+
</div>
33+
<h1 class="text-3xl font-semibold text-headings">{entry.data.title}</h1>
34+
</div>
35+
<div class="relative aspect-video overflow-hidden rounded-lg">
36+
<Image
37+
src={entry.data.image}
38+
alt={entry.data.title}
39+
class="object-cover"
40+
/>
41+
</div>
42+
<div class="prose dark:prose-invert">
43+
<Content />
44+
</div>
45+
</article>
46+
</Container>
47+
</BaseLayout>
48+

0 commit comments

Comments
 (0)