2022-02-14 20:32:58 +00:00
|
|
|
import Link from 'next/link';
|
|
|
|
import Layout from '../../components/layout';
|
2022-10-05 03:41:59 +00:00
|
|
|
import date from '../../lib/date';
|
|
|
|
import { getPostsMeta, IPostMeta } from '../../lib/slug';
|
2022-02-14 20:32:58 +00:00
|
|
|
|
2022-10-05 03:41:59 +00:00
|
|
|
function PostsPage({ postsMeta }: { postsMeta: IPostMeta[] }) {
|
2022-04-30 13:56:18 +00:00
|
|
|
return (
|
2022-02-14 20:32:58 +00:00
|
|
|
<Layout name='Posts'>
|
2022-10-05 03:41:59 +00:00
|
|
|
<table>
|
2022-04-30 13:56:18 +00:00
|
|
|
<tbody>
|
2022-10-05 03:41:59 +00:00
|
|
|
{
|
|
|
|
postsMeta.length &&
|
|
|
|
postsMeta.map((post: IPostMeta, i) => {
|
|
|
|
return <tr key={i} style={{alignItems: 'center'}}>
|
|
|
|
<td style={{display: 'inline-block', textAlign: 'right', fontSize: '0.9rem'}}>
|
|
|
|
<div style={{fontStyle: 'italics', fontSize: '.8rem'}}>{
|
|
|
|
post.last_updated && `updated ${date.toRelativeDate(new Date(post.last_updated))}`
|
|
|
|
}</div>
|
|
|
|
<div>{ date.toRelativeDate(new Date(post.created_at)) }</div>
|
2022-04-30 13:56:18 +00:00
|
|
|
</td>
|
2022-10-05 03:41:59 +00:00
|
|
|
<td style={{
|
|
|
|
flex: '1 1 60%',
|
|
|
|
alignItems: 'center',
|
|
|
|
fontFamily: `'EB Garamond', 'Garamond', 'Times New Roman', Times, serif`}}>
|
|
|
|
<Link href={`/posts/${post.slug}`} >
|
|
|
|
<a style={{textDecoration: 'none'}}>{post.title}</a>
|
|
|
|
</Link>
|
2022-04-30 13:56:18 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2022-10-05 03:41:59 +00:00
|
|
|
}) ||
|
|
|
|
<div className='text center'>
|
|
|
|
<div>**crickets**</div>
|
|
|
|
<div>No posts found...</div>
|
|
|
|
<div><Link href='/'><a className='link button green back'>Go Home</a></Link></div>
|
|
|
|
</div>
|
|
|
|
}
|
2022-04-30 13:56:18 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2022-02-14 20:32:58 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-04-27 10:39:10 +00:00
|
|
|
export async function getStaticProps() {
|
2022-04-27 08:03:21 +00:00
|
|
|
return {
|
|
|
|
props: { postsMeta: getPostsMeta() }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-28 16:37:12 +00:00
|
|
|
export default PostsPage;
|