jonbio/app/Main.tsx

92 lines
3.6 KiB
TypeScript
Raw Normal View History

import Link from '@/components/Link'
2021-02-25 00:04:02 +01:00
import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
2023-07-07 11:17:22 +08:00
import { formatDate } from 'pliny/utils/formatDate'
2023-07-16 18:52:51 +08:00
import NewsletterForm from 'pliny/ui/NewsletterForm'
2021-08-18 17:33:15 +02:00
2021-01-09 17:50:45 +08:00
const MAX_DISPLAY = 5
export default function Home({ posts }) {
return (
<>
2021-01-09 17:50:45 +08:00
<div className="divide-y divide-gray-200 dark:divide-gray-700">
2023-07-07 11:17:22 +08:00
<div className="space-y-2 pb-8 pt-6 md:space-y-5">
2021-01-12 23:35:36 +08:00
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-6xl md:leading-14">
2021-01-09 17:50:45 +08:00
Latest
</h1>
<p className="text-lg leading-7 text-gray-500 dark:text-gray-400">
{siteMetadata.description}
</p>
</div>
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
{!posts.length && 'No posts found.'}
2023-07-07 11:17:22 +08:00
{posts.slice(0, MAX_DISPLAY).map((post) => {
const { slug, date, title, summary, tags } = post
2021-01-09 17:50:45 +08:00
return (
<li key={slug} className="py-12">
<article>
2022-01-31 23:58:10 +08:00
<div className="space-y-2 xl:grid xl:grid-cols-4 xl:items-baseline xl:space-y-0">
<dl>
<dt className="sr-only">Published on</dt>
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
2023-07-07 11:17:22 +08:00
<time dateTime={date}>{formatDate(date, siteMetadata.locale)}</time>
</dd>
</dl>
<div className="space-y-5 xl:col-span-3">
<div className="space-y-6">
<div>
<h2 className="text-2xl font-bold leading-8 tracking-tight">
<Link
href={`/blog/${slug}`}
className="text-gray-900 dark:text-gray-100"
>
{title}
</Link>
</h2>
2021-02-06 16:54:20 +08:00
<div className="flex flex-wrap">
{tags.map((tag) => (
<Tag key={tag} text={tag} />
))}
</div>
</div>
2022-01-31 23:58:10 +08:00
<div className="prose max-w-none text-gray-500 dark:text-gray-400">
{summary}
2021-01-09 17:50:45 +08:00
</div>
</div>
<div className="text-base font-medium leading-6">
<Link
href={`/blog/${slug}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
aria-label={`Read "${title}"`}
>
Read more &rarr;
</Link>
2021-01-09 17:50:45 +08:00
</div>
</div>
</div>
</article>
</li>
)
})}
</ul>
</div>
{posts.length > MAX_DISPLAY && (
2021-01-12 23:35:36 +08:00
<div className="flex justify-end text-base font-medium leading-6">
2021-01-10 16:09:38 +08:00
<Link
href="/blog"
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
2023-07-07 11:17:22 +08:00
aria-label="All posts"
2021-01-10 16:09:38 +08:00
>
All Posts &rarr;
2021-01-09 17:50:45 +08:00
</Link>
</div>
)}
2023-07-07 11:17:22 +08:00
{siteMetadata.newsletter?.provider && (
<div className="flex items-center justify-center pt-4">
2021-09-11 16:36:59 +08:00
<NewsletterForm />
2021-09-10 14:32:18 +02:00
</div>
)}
</>
2021-01-09 17:50:45 +08:00
)
}