www/pages/posts/index.tsx

49 lines
1.6 KiB
TypeScript
Raw Normal View History

import Link from 'next/link';
import Layout from '../../components/layout';
2022-04-28 01:55:18 +00:00
import date from '../../util/date';
2022-04-27 08:03:21 +00:00
import { getPostsMeta, PostMeta } from '../../util/slug';
2022-04-28 16:37:12 +00:00
function PostsPage({ postsMeta }: { postsMeta: PostMeta[] }) {
2022-04-30 13:56:18 +00:00
return (
<Layout name='Posts'>
2022-04-30 13:56:18 +00:00
<table className='h5'>
<thead>
<tr>
<th style={{flex: '1 0 30%'}}>Name</th>
<th>Created on</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
{postsMeta.map((post: PostMeta, i) => {
return <tr key={i}>
<td style={{flex: '1 0 30%'}}>
<Link href={`/posts/${post.slug}`}>
{post.title}
</Link>
</td>
<td>
{date.prettyPrint(new Date(post.created_at))}
</td>
<td>
{
post.last_updated
? date.prettyPrint(new Date(post.last_updated))
: '-'
}
</td>
</tr>
})}
</tbody>
</table>
</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;