2021-12-08 03:38:31 +00:00
|
|
|
import Link from 'next/link';
|
|
|
|
import React from 'react';
|
|
|
|
import Layout from '../components/layout';
|
|
|
|
import Pages from '../public/pages.json';
|
2022-04-24 04:27:51 +00:00
|
|
|
import style from '../styles/home.module.css';
|
|
|
|
import prettyDatePrint from '../util/pretty-date';
|
2022-04-27 08:03:21 +00:00
|
|
|
import { getPostsMeta, PostMeta } from '../util/slug';
|
2021-12-08 03:38:31 +00:00
|
|
|
|
2022-04-27 08:03:21 +00:00
|
|
|
function HomePage(props: {postsMeta: PostMeta[]}) {
|
|
|
|
props.postsMeta.sort((x, y) => { return (x.title).localeCompare(y.title) });
|
2021-12-08 03:38:31 +00:00
|
|
|
return (
|
|
|
|
<Layout name='' title='PaulW.XYZ'>
|
2022-02-14 20:32:58 +00:00
|
|
|
<section className='block'>
|
|
|
|
<div className='h2'>Welcome!</div>
|
|
|
|
{
|
2021-12-08 03:38:31 +00:00
|
|
|
Pages.map(obj => {
|
2022-04-24 04:27:51 +00:00
|
|
|
return <span key={obj.link}>
|
2021-12-08 03:38:31 +00:00
|
|
|
<Link href={obj.link}>
|
2022-04-24 04:27:51 +00:00
|
|
|
<a className={style.button}>{obj.title}</a>
|
2021-12-08 03:38:31 +00:00
|
|
|
</Link>
|
2022-04-24 04:27:51 +00:00
|
|
|
</span>
|
2021-12-08 03:38:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
</section>
|
2022-02-14 20:32:58 +00:00
|
|
|
<section className='block'>
|
2022-04-24 04:27:51 +00:00
|
|
|
<table style={{ width: '100%' }}>
|
|
|
|
<th className='h2'>Posts</th> <th>Posted</th>
|
2022-04-27 08:03:21 +00:00
|
|
|
{props.postsMeta?.map((post: any) => {
|
2022-04-24 04:27:51 +00:00
|
|
|
return <tr key={post.slug}>
|
|
|
|
<td className='h5'>
|
|
|
|
<Link href={`posts/${post.slug}`}>
|
|
|
|
{post.title}
|
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
<td>{prettyDatePrint(new Date(post.created_at))}</td>
|
|
|
|
|
|
|
|
</tr>
|
2022-02-14 20:32:58 +00:00
|
|
|
})}
|
2022-04-24 04:27:51 +00:00
|
|
|
</table>
|
2022-02-14 20:32:58 +00:00
|
|
|
</section>
|
2021-12-08 03:38:31 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-04-27 08:03:21 +00:00
|
|
|
export async function getServerSideProps() {
|
|
|
|
return {
|
|
|
|
props: { postsMeta: getPostsMeta() }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-02-14 20:32:58 +00:00
|
|
|
export default HomePage;
|