MCPcopy Create free account
hub / github.com/vercel/examples / BlogPosts

Function BlogPosts

solutions/blog/app/components/posts.tsx:4–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { formatDate, getBlogPosts } from 'app/blog/utils'
3
4export function BlogPosts() {
5 let allBlogs = getBlogPosts()
6
7 return (
8 <div>
9 {allBlogs
10 .sort((a, b) => {
11 if (
12 new Date(a.metadata.publishedAt) > new Date(b.metadata.publishedAt)
13 ) {
14 return -1
15 }
16 return 1
17 })
18 .map((post) => (
19 <Link
20 key={post.slug}
21 className="flex flex-col space-y-1 mb-4"
22 href={`/blog/${post.slug}`}
23 >
24 <div className="w-full flex flex-col md:flex-row space-x-0 md:space-x-2">
25 <p className="text-neutral-600 dark:text-neutral-400 w-[100px] tabular-nums">
26 {formatDate(post.metadata.publishedAt, false)}
27 </p>
28 <p className="text-neutral-900 dark:text-neutral-100 tracking-tight">
29 {post.metadata.title}
30 </p>
31 </div>
32 </Link>
33 ))}
34 </div>
35 )
36}

Callers

nothing calls this directly

Calls 2

getBlogPostsFunction · 0.90
formatDateFunction · 0.90

Tested by

no test coverage detected