www/pages/posts/index.tsx

38 lines
1.4 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-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
<Layout name='Posts'>
<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>
</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}`}>
{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>}
</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;