--- import { getCollection } from 'astro:content'; import BaseLayout from '@/layouts/BaseLayout.astro'; import Heading from '@/components/ui/Heading.astro'; import Search from '@/components/blog/Search.astro'; import { Pagination, PaginationContent, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from '@/components/ui/pagination'; import { Image } from 'astro:assets'; interface BlogPost { data: { title: string; description: string; datePublished?: string; dateModified?: string; author?: [ { type?: string; name: string; url?: string; }, ]; image?: string; isDraft?: boolean; }; slug: string; } export async function getStaticPaths({ paginate }: { paginate: Function }) { const allBlogposts = await getCollection('blog'); const publishedBlogPosts: any = (post: BlogPost) => !post.data.isDraft; const sortedPosts = allBlogposts.filter(publishedBlogPosts).sort((a, b) => { const dateA = a.data.dateModified ? new Date(a.data.dateModified) : a.data.datePublished ? new Date(a.data.datePublished) : new Date(0); const dateB = b.data.dateModified ? new Date(b.data.dateModified) : b.data.datePublished ? new Date(b.data.datePublished) : new Date(0); return dateB.getTime() - dateA.getTime(); }); const postsPerPage = 6; return paginate(sortedPosts, { pageSize: postsPerPage, }); } const { page, }: { page: { data: BlogPost[]; url: { prev: string; current: string; next: string }; currentPage: number; lastPage: number; }; } = Astro.props; ---
Blog

Here are some blogposts, they are located in the repository as mdx files.


{ page.data.map((post) => (
{post.data.image && ( {post.data.title} )}

{post.data.title}

{post.data.author && ( <> By {post.data.author.map((author, index) => ( {author.url ? ( {author.name} ) : ( {author.name} )} {post.data.author && index < post.data.author.length - 1 && ( , )} ))} )}
{post.data.datePublished && ( )} {post.data.dateModified && ( )}

{post.data.description}

)) }
{ page.currentPage > 1 && ( <> 1 ) } {page.currentPage} { page.currentPage < page.lastPage && ( <> {page.lastPage} ) }