2022-02-14 20:32:58 +00:00
|
|
|
import Link from 'next/link';
|
|
|
|
import React from 'react';
|
|
|
|
import Layout from '../../components/layout';
|
2022-04-24 04:27:51 +00:00
|
|
|
import Posts from '../../public/posts.json';
|
|
|
|
import prettyDatePrint from '../../util/pretty-date';
|
2022-02-14 20:32:58 +00:00
|
|
|
|
|
|
|
function HomePage({posts}: any) {
|
2022-04-24 04:40:26 +00:00
|
|
|
Posts.sort((x, y) => { return (x as any).title.localeCompare((x as any).title) });
|
2022-04-24 04:27:51 +00:00
|
|
|
// todo: create a table-like interface
|
2022-02-14 20:32:58 +00:00
|
|
|
return (
|
|
|
|
<Layout name='Posts'>
|
2022-04-24 04:27:51 +00:00
|
|
|
<>
|
|
|
|
<section className='h4 block'>
|
|
|
|
Post Name <span style={{float: 'right', margin: 'auto 1rem'}}> Created on </span> <span style={{float: 'right', margin: 'auto 1rem'}}>Last Updated </span>
|
|
|
|
</section>
|
|
|
|
{Posts.map((post: any) => {
|
2022-02-14 20:32:58 +00:00
|
|
|
return <section key='' className='h5 block'>
|
|
|
|
<Link href={`posts/${post.slug}`}>
|
|
|
|
{post.title}
|
|
|
|
</Link>
|
2022-04-24 04:27:51 +00:00
|
|
|
<span className='h6' style={{float: 'right', margin: 'auto 1rem'}}>{prettyDatePrint(new Date(post.created_at))}</span>
|
|
|
|
{post.last_updated ? <span className='h6' style={{float: 'right', margin: 'auto 1rem'}}>{prettyDatePrint(new Date(post.last_updated))}</span> : ''}
|
2022-02-14 20:32:58 +00:00
|
|
|
</section>
|
|
|
|
})}
|
2022-04-24 04:27:51 +00:00
|
|
|
</>
|
2022-02-14 20:32:58 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default HomePage;
|