portfolio/pages/writing/index.tsx

72 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-01-14 19:31:05 +00:00
import {GetStaticProps} from 'next'
2022-12-06 12:54:34 +00:00
import Head from 'next/head'
import {Card} from '@/components/Card'
import {SimpleLayout} from '@/components/SimpleLayout'
import {getAllArticles} from '@/lib/getAllArticles'
import {formatDate} from '@/lib/formatDate'
2023-01-14 19:31:05 +00:00
import {Article} from 'types'
function Article({article}: { article: Article }) {
2022-12-06 12:54:34 +00:00
return (
2023-01-05 20:03:09 +00:00
<article>
<Card small={true}>
2022-12-06 12:54:34 +00:00
<Card.Title href={`/writing/${article.slug}`}>
{article.title}
</Card.Title>
<Card.Eyebrow
as="time"
dateTime={article.date}
decorate={false}
2023-01-27 00:01:38 +00:00
className="flex-shrink-0 md:order-last mb-3 md:mb-0"
2022-12-06 12:54:34 +00:00
>
{formatDate(article.date)}
</Card.Eyebrow>
</Card>
</article>
)
}
2023-01-14 19:31:05 +00:00
export default function ArticlesIndex({articles}: { articles: Article[] }) {
2022-12-06 12:54:34 +00:00
return (
<>
<Head>
<title>Writing - Ryan Freeman</title>
<meta
name="description"
content="Writing on software engineering, and everything in between."
/>
<meta
property="og:title"
content="Writing - Ryan Freeman"
/>
<meta
property="og:description"
content="Writing on software engineering, and everything in between."
/>
</Head>
<SimpleLayout
title="Writing on software engineering, and everything in between."
intro="All of my long-form thoughts on software engineering, and more, displayed in chronological order."
gradient="bg-gradient-to-r from-pink-500 to-violet-500"
>
2023-01-05 20:03:09 +00:00
<div>
<div className="max-w-3xl space-y-16">
2022-12-06 12:54:34 +00:00
{articles.map((article) => (
<Article key={article.slug} article={article}/>
))}
</div>
</div>
</SimpleLayout>
</>
)
}
2023-01-14 19:31:05 +00:00
export const getStaticProps: GetStaticProps = async () => {
2022-12-06 12:54:34 +00:00
return {
props: {
articles: (await getAllArticles()).map(({component, ...meta}) => meta),
2023-01-14 19:31:05 +00:00
}
2022-12-06 12:54:34 +00:00
}
2023-01-14 19:31:05 +00:00
}