www/components/recent-notes.tsx
Paul W. 13be540ebd
Update readme, about, and some minor things
Signed-off-by: Paul W. <lambdapaul@protonmail.com>
2024-04-20 16:00:22 -04:00

41 lines
1.0 KiB
TypeScript

import Link from "next/link";
import NotesInfo from '../public/notes.json';
function RecentNotes() {
const notes = Object.entries(NotesInfo)
.map(([slug, note]) => {
return {
slug,
title: note.title,
mtime: new Date(note.mtime)
}
})
.sort(
(a, b) => {
return b.mtime.getTime() - a.mtime.getTime();
}
);
return (
<div className='block'>
<h2>Recent Notes</h2>
<ul>
{notes?.slice(0, 5)
.map(({slug, title, mtime}) => {
return (
<li key={mtime.getTime()} >
<Link href={`/notes/${slug}`}>{title}</Link>
</li>
);
})
}
{
notes.length > 5 &&
<Link href='/notes'>More...</Link>
}
</ul>
</div>
);
}
export default RecentNotes;