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'; function HomePage({posts}: any) { Pages.sort((x, y) => { return ('' + x.title).localeCompare(y.title) }); return (
Welcome!
{ Pages.map(obj => { return
{obj.title}{obj.link.match('^http*')? ' ↗' : ''}
}) }
Posts
{posts?.map((post: any) => { return
[{ (new Date(post.last_updated)).toLocaleString()}] {post.title}
})}
) } export async function getStaticProps() { // make this webpack plugin return { props: {posts: cachePostLinkData()} }; } export default HomePage;