2022-04-28 16:37:12 +00:00
|
|
|
import Link from 'next/link';
|
|
|
|
import Layout from '../../components/layout';
|
2023-10-30 04:18:38 +00:00
|
|
|
|
2022-10-05 03:41:59 +00:00
|
|
|
import date from '../../lib/date';
|
2023-10-30 04:18:38 +00:00
|
|
|
import NotesInfo from '../../public/notes.json';
|
2022-04-28 16:37:12 +00:00
|
|
|
|
2023-10-30 04:18:38 +00:00
|
|
|
function NoteEntry(props: { path: string, note: { title: string, mtime: string } }) {
|
2022-04-28 16:37:12 +00:00
|
|
|
return (
|
2023-10-30 04:18:38 +00:00
|
|
|
<tr>
|
|
|
|
<td style={{ flex: '1 0 50%' }}>
|
|
|
|
<Link href={props.path}>
|
|
|
|
{props.note.title}
|
|
|
|
</Link>
|
|
|
|
</td>
|
|
|
|
<td style={{ fontStyle: 'italic' }}>
|
|
|
|
{props.note.mtime && date.toRelativeDate(new Date(props.note.mtime))}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function NotesPage() {
|
|
|
|
const notes = Object.entries(NotesInfo);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Layout>
|
|
|
|
{!notes || notes.length === 0 && <>No notes found</> || <table>
|
2022-10-05 03:41:59 +00:00
|
|
|
<tbody>
|
2023-10-30 04:18:38 +00:00
|
|
|
{notes.map(([slug, note]: any, i: number) => {
|
|
|
|
return <NoteEntry path={`/notes/${slug}`} note={note} key={i} />
|
|
|
|
})}
|
2022-10-05 03:41:59 +00:00
|
|
|
</tbody>
|
2023-10-30 04:18:38 +00:00
|
|
|
</table>}
|
2022-04-28 16:37:12 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-30 04:18:38 +00:00
|
|
|
export default NotesPage;
|