diff --git a/src/pages/blog/[...id].astro b/src/pages/blog/[...id].astro index 26a3f59..1a790a6 100644 --- a/src/pages/blog/[...id].astro +++ b/src/pages/blog/[...id].astro @@ -1,55 +1,55 @@ --- -import Breadcrumbs from '@/components/Breadcrumbs.astro' -import PostNavigation from '@/components/PostNavigation.astro' -import TableOfContents from '@/components/TableOfContents.astro' -import { Button } from '@/components/ui/button' -import { Separator } from '@/components/ui/separator' -import Layout from '@/layouts/Layout.astro' -import { parseAuthors } from '@/lib/server-utils' -import { formatDate, readingTime } from '@/lib/utils' -import { Icon } from 'astro-icon/components' -import { Image } from 'astro:assets' -import { type CollectionEntry, getCollection, render } from 'astro:content' +import { Image } from "astro:assets"; +import { type CollectionEntry, getCollection, render } from "astro:content"; +import Breadcrumbs from "@/components/Breadcrumbs.astro"; +import PostNavigation from "@/components/PostNavigation.astro"; +import TableOfContents from "@/components/TableOfContents.astro"; +import { Button } from "@/components/ui/button"; +import { Separator } from "@/components/ui/separator"; +import Layout from "@/layouts/Layout.astro"; +import { parseAuthors } from "@/lib/server-utils"; +import { formatDate, readingTime } from "@/lib/utils"; +import { Icon } from "astro-icon/components"; export async function getStaticPaths() { - const posts = (await getCollection('blog')) - .filter((post) => !post.data.draft) - .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) - return posts.map((post) => ({ - params: { id: post.id }, - props: post, - })) + const posts = (await getCollection("blog")) + .filter((post) => !post.data.draft) + .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()); + return posts.map((post) => ({ + params: { id: post.id }, + props: post, + })); } -type Props = CollectionEntry<'blog'> +type Props = CollectionEntry<"blog">; -const posts = (await getCollection('blog')) - .filter((post) => !post.data.draft) - .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()) +const posts = (await getCollection("blog")) + .filter((post) => !post.data.draft) + .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf()); function getPostIndex(id: string): number { - return posts.findIndex((post) => post.id === id) + return posts.findIndex((post) => post.id === id); } function getPrevPost(id: string): Props | null { - const postIndex = getPostIndex(id) - return postIndex !== -1 && postIndex < posts.length - 1 - ? posts[postIndex + 1] - : null + const postIndex = getPostIndex(id); + return postIndex !== -1 && postIndex < posts.length - 1 + ? posts[postIndex + 1] + : null; } function getNextPost(id: string): Props | null { - const postIndex = getPostIndex(id) - return postIndex > 0 ? posts[postIndex - 1] : null + const postIndex = getPostIndex(id); + return postIndex > 0 ? posts[postIndex - 1] : null; } -const currentPostId = Astro.params.id -const nextPost = getNextPost(currentPostId) -const prevPost = getPrevPost(currentPostId) +const currentPostId = Astro.params.id; +const nextPost = getNextPost(currentPostId); +const prevPost = getPrevPost(currentPostId); -const post = Astro.props -const { Content, headings } = await render(post) +const post = Astro.props; +const { Content, headings } = await render(post); -const authors = await parseAuthors(post.data.authors ?? []) +const authors = await parseAuthors(post.data.authors ?? []); --- @@ -99,8 +99,6 @@ const authors = await parseAuthors(post.data.authors ?? [])
- -