0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-04 08:30:27 +03:00

Refactor Astro components and layouts

This commit is contained in:
2024-09-12 16:36:57 +00:00
parent 0b57b888ca
commit 3376c53b2e
7 changed files with 21 additions and 72 deletions

View File

@ -1,25 +1,20 @@
---
import { type CollectionEntry, getCollection } from "astro:content";
import Comments from "../../components/Comments.astro";
import Layout from "../../layouts/PageLayout.astro";
import Pagination from "../../components/PostPagination.astro";
import Layout from "../../layouts/BaseLayout.astro";
export async function getStaticPaths() {
const posts = await getCollection("blog");
const total = posts.length;
return posts.map((post, index) => ({
return posts.map((post) => ({
params: { slug: post.slug },
props: {
post,
prevPost: index + 1 === total ? null : posts[index + 1],
nextPost: index === 0 ? null : posts[index - 1],
},
props: post,
}));
}
type Props = CollectionEntry<"blog">;
const { post, prevPost, nextPost } = Astro.props;
const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render();
---
@ -47,10 +42,6 @@ const { Content, remarkPluginFrontmatter } = await post.render();
<Content />
</section>
<section>
<Pagination prevPost={prevPost} nextPost={nextPost} />
</section>
<section>
<Comments />
</section>