|
1 | | -import Link from 'next/link'; |
2 | | - |
3 | | -import ArrowCard from '@/components/arrow-card'; |
4 | | -import client from '@/tina/__generated__/client'; |
5 | | - |
6 | | -const LatestPosts: React.FC = async () => { |
7 | | - const { data } = await client.queries.postConnection({ last: 3, sort: 'date' }); |
8 | | - |
9 | | - return ( |
10 | | - <section className="space-y-6"> |
11 | | - <div className="flex justify-between items-center"> |
12 | | - <h3 className="font-semibold text-black dark:text-white">最近的文章</h3> |
13 | | - <Link href="/posts" className="link"> |
14 | | - 查看所有文章 |
15 | | - </Link> |
16 | | - </div> |
17 | | - |
18 | | - <ul className="flex flex-col gap-4"> |
19 | | - {data.postConnection.edges?.map((post) => ( |
20 | | - <li key={post?.node?.id}> |
21 | | - <Link href={`/posts/${post?.node?._sys.breadcrumbs.join('/')}`}> |
22 | | - <ArrowCard title={post?.node?.title} /> |
23 | | - </Link> |
24 | | - </li> |
25 | | - ))} |
26 | | - </ul> |
27 | | - </section> |
28 | | - ); |
29 | | -}; |
30 | | - |
31 | | -export default LatestPosts; |
| 1 | +import Link from 'next/link'; |
| 2 | + |
| 3 | +import ArrowCard from '@/components/arrow-card'; |
| 4 | +import NavLink from '@/components/nav-link'; |
| 5 | +import client from '@/tina/__generated__/client'; |
| 6 | + |
| 7 | +const LatestPosts: React.FC = async () => { |
| 8 | + const { data } = await client.queries.postConnection({ last: 3, sort: 'date' }); |
| 9 | + |
| 10 | + return ( |
| 11 | + <section className="space-y-6"> |
| 12 | + <div className="flex justify-between items-center"> |
| 13 | + <h3 className="font-semibold text-black dark:text-white">最近的文章</h3> |
| 14 | + <NavLink href="/posts">查看所有文章</NavLink> |
| 15 | + </div> |
| 16 | + |
| 17 | + <ul className="flex flex-col gap-4"> |
| 18 | + {data.postConnection.edges?.map((post) => ( |
| 19 | + <li key={post?.node?.id}> |
| 20 | + <Link href={`/posts/${post?.node?._sys.breadcrumbs.join('/')}`}> |
| 21 | + <ArrowCard title={post?.node?.title} /> |
| 22 | + </Link> |
| 23 | + </li> |
| 24 | + ))} |
| 25 | + </ul> |
| 26 | + </section> |
| 27 | + ); |
| 28 | +}; |
| 29 | + |
| 30 | +export default LatestPosts; |
0 commit comments