www/pages/index.tsx

47 lines
1.5 KiB
TypeScript
Raw Normal View History

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';
import cachePostLinkData from '../util/post-cache';
2021-12-08 03:38:31 +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'>
<section className='block'>
<div className='h2'>Welcome!</div>
{
2021-12-08 03:38:31 +00:00
Pages.map(obj => {
return <div key='' className='h5'>
2021-12-08 03:38:31 +00:00
<Link href={obj.link}>
<a>{obj.title}{obj.link.match('^http*')? ' ↗' : ''}</a>
2021-12-08 03:38:31 +00:00
</Link>
</div>
})
}
</section>
<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>
)
}
export async function getStaticProps() {
// make this webpack plugin
return {
props: {posts: cachePostLinkData()}
};
}
2021-12-08 03:38:31 +00:00
export default HomePage;