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-02-14 20:32:58 +00:00
|
|
|
import cachePostLinkData from '../util/post-cache';
|
2021-12-08 03:38:31 +00:00
|
|
|
|
|
|
|
|
2022-02-14 20:32:58 +00:00
|
|
|
function HomePage({posts}: any) {
|
|
|
|
Pages.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-02-14 20:32:58 +00:00
|
|
|
return <div key='' className='h5'>
|
2021-12-08 03:38:31 +00:00
|
|
|
<Link href={obj.link}>
|
2022-02-14 20:32:58 +00:00
|
|
|
<a>{obj.title}{obj.link.match('^http*')? ' ↗' : ''}</a>
|
2021-12-08 03:38:31 +00:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</section>
|
2022-02-14 20:32:58 +00:00
|
|
|
<section className='block'>
|
|
|
|
<div className='h2'>Posts</div>
|
|
|
|
<div>
|
|
|
|
{posts?.map((post: any) => {
|
|
|
|
return <div key={post.slug} className='h5'>
|
|
|
|
[{ (new Date(post.last_updated)).toLocaleString()}] <Link href={`posts/${post.slug}`}>
|
|
|
|
{post.title}
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-12-08 03:38:31 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-14 20:32:58 +00:00
|
|
|
export async function getStaticProps() {
|
|
|
|
// make this webpack plugin
|
|
|
|
return {
|
|
|
|
props: {posts: cachePostLinkData()}
|
|
|
|
};
|
|
|
|
}
|
2021-12-08 03:38:31 +00:00
|
|
|
|
2022-02-14 20:32:58 +00:00
|
|
|
export default HomePage;
|