www/pages/notes/index.tsx

41 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 NotesInfo from '../../public/notes.json';
2022-04-28 16:37:12 +00:00
function NoteEntry(props: { path: string, note: { title: string, mtime: string } }) {
2022-04-28 16:37:12 +00:00
return (
<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>
{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>
</table>}
2022-04-28 16:37:12 +00:00
</Layout>
)
}
export default NotesPage;