diff --git a/templates/blog/src/pages/blog/[...slug].astro b/templates/blog/src/pages/blog/[...slug].astro index 07dbce26..12e0e2d5 100644 --- a/templates/blog/src/pages/blog/[...slug].astro +++ b/templates/blog/src/pages/blog/[...slug].astro @@ -1,15 +1,15 @@ --- -import { type CollectionEntry, getCollection } from 'astro:content'; -import BlogPost from '../../layouts/BlogPost.astro'; +import { type CollectionEntry, getCollection } from "astro:content"; +import BlogPost from "../../layouts/BlogPost.astro"; export async function getStaticPaths() { - const posts = await getCollection('blog'); - return posts.map((post) => ({ + const posts = await getCollection("blog"); + return posts.map((post: CollectionEntry<"blog">) => ({ params: { slug: post.slug }, props: post, })); } -type Props = CollectionEntry<'blog'>; +type Props = CollectionEntry<"blog">; const post = Astro.props; const { Content } = await post.render(); diff --git a/templates/blog/src/pages/blog/index.astro b/templates/blog/src/pages/blog/index.astro index a1019da5..27c8b25b 100644 --- a/templates/blog/src/pages/blog/index.astro +++ b/templates/blog/src/pages/blog/index.astro @@ -1,13 +1,14 @@ --- -import BaseHead from '../../components/BaseHead.astro'; -import Header from '../../components/Header.astro'; -import Footer from '../../components/Footer.astro'; -import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts'; -import { getCollection } from 'astro:content'; -import FormattedDate from '../../components/FormattedDate.astro'; +import BaseHead from "../../components/BaseHead.astro"; +import Header from "../../components/Header.astro"; +import Footer from "../../components/Footer.astro"; +import { SITE_TITLE, SITE_DESCRIPTION } from "../../consts"; +import { type CollectionEntry, getCollection } from "astro:content"; +import FormattedDate from "../../components/FormattedDate.astro"; -const posts = (await getCollection('blog')).sort( - (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), +const posts = (await getCollection("blog")).sort( + (a: CollectionEntry<"Blog">, b: CollectionEntry<"Blog">) => + b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), ); --- @@ -91,13 +92,20 @@ const posts = (await getCollection('blog')).sort(