2022-02-14 20:32:58 +00:00
|
|
|
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-02-14 20:32:58 +00:00
|
|
|
|
2022-04-28 16:37:12 +00:00
|
|
|
function PostsPage({ postsMeta }: { postsMeta: PostMeta[] }) {
|
2022-04-27 08:03:21 +00:00
|
|
|
// todo: create a table-like user interface
|
2022-04-28 01:55:18 +00:00
|
|
|
return ( // wow this is horrible
|
2022-02-14 20:32:58 +00:00
|
|
|
<Layout name='Posts'>
|
2022-04-24 04:27:51 +00:00
|
|
|
<section className='h4 block'>
|
2022-04-28 01:55:18 +00:00
|
|
|
Post Name
|
|
|
|
<span style={{ float: 'right', margin: 'auto 1rem' }}> Created on </span>
|
|
|
|
<span style={{ float: 'right', margin: 'auto 1rem' }}>Last Updated </span>
|
2022-04-24 04:27:51 +00:00
|
|
|
</section>
|
2022-04-28 01:55:18 +00:00
|
|
|
{postsMeta.map((post: PostMeta, i) => {
|
|
|
|
return <section key={i} className='h5 block'>
|
|
|
|
<Link href={`/posts/${post.slug}`}>
|
2022-02-14 20:32:58 +00:00
|
|
|
{post.title}
|
|
|
|
</Link>
|
2022-04-28 01:55:18 +00:00
|
|
|
<span className='h6' style={{ float: 'right', margin: 'auto 1rem' }}>
|
|
|
|
{date.prettyPrint(new Date(post.created_at))}
|
|
|
|
</span>
|
|
|
|
{post.last_updated && <span className='h6' style={{ float: 'right', margin: 'auto 1rem' }}>
|
|
|
|
{date.prettyPrint(new Date(post.last_updated))}
|
|
|
|
</span>}
|
2022-02-14 20:32:58 +00:00
|
|
|
</section>
|
|
|
|
})}
|
|
|
|
</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;
|