1
0
mirror of https://github.com/avinal/avinal.github.io.git synced 2026-07-04 07:40:09 +05:30
Files
avinal.github.io/src/pages/posts/[...slug].astro
T
avinal ef70634b2a feat: add events page and music widget
- add music source from Listenbrainz, easter egg and evets page
- update design of resume page

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
2026-02-26 17:22:08 +05:30

33 lines
825 B
Plaintext

---
import { getCollection, render } from "astro:content";
import PostLayout from "@/layouts/PostLayout.astro";
export async function getStaticPaths() {
const posts = await getCollection("posts", ({ data }) => !data.draft);
return posts.map((post) => ({
params: { slug: post.id },
props: { post },
}));
}
const { post } = Astro.props;
const { Content } = await render(post);
const wordCount = post.body?.split(/\s+/).length ?? 0;
const minutes = Math.max(1, Math.round(wordCount / 220));
const readingTime = `${minutes} min read`;
---
<PostLayout
title={post.data.title}
description={post.data.description}
date={post.data.date}
modified={post.data.modified}
category={post.data.category}
tags={post.data.tags}
image={post.data.image}
readingTime={readingTime}
>
<Content />
</PostLayout>