www/pages/notes/index.tsx

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-04-28 16:37:12 +00:00
import Link from 'next/link';
import Layout from '../../components/layout';
2022-10-05 03:41:59 +00:00
import date from '../../lib/date';
import { getNotesMeta, INoteMeta } from '../../lib/slug';
2022-04-28 16:37:12 +00:00
2022-10-05 03:41:59 +00:00
function NotesPage({ notesMeta }: { notesMeta: INoteMeta[] }) {
2022-04-28 16:37:12 +00:00
return (
<Layout name='Notes'>
2022-10-05 03:41:59 +00:00
<table>
<tbody>
{notesMeta && notesMeta.map((note: INoteMeta, i) => {
return (
<tr key={i}>
<td style={{flex: '1 0 50%'}}>
<Link href={`/notes/${note.slug}`}>
{note.title}
</Link>
</td>
<td style={{fontStyle: 'italic'}}>
{note.last_updated && date.toRelativeDate(new Date(note.last_updated))}
</td>
</tr>
)})}
</tbody>
</table>
2022-04-28 16:37:12 +00:00
</Layout>
)
}
export async function getStaticProps() {
return {
props: { notesMeta: getNotesMeta() }
};
}
export default NotesPage;