From 3376c53b2ee91041d5eaa0f9274da0affd7d4a9d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 12 Sep 2024 16:36:57 +0000 Subject: Refactor Astro components and layouts --- src/pages/blog/[...slug].astro | 19 +++++-------------- src/pages/index.astro | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/pages') diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 9262a66..6754653 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -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(); -
- -
-
diff --git a/src/pages/index.astro b/src/pages/index.astro index 4380bbc..6df8f31 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,7 +1,7 @@ --- import { getCollection } from "astro:content"; import Element from "../components/PostElement.astro"; -import Layout from "../layouts/PageLayout.astro"; +import Layout from "../layouts/BaseLayout.astro"; const posts = await getCollection("blog"); --- -- cgit v1.2.3