2022-04-28 12:37:12 -04:00
|
|
|
import Link from "next/link";
|
2023-10-30 00:18:38 -04:00
|
|
|
import NotesInfo from '../public/notes.json';
|
2022-04-28 12:37:12 -04:00
|
|
|
|
2023-10-30 00:18:38 -04:00
|
|
|
function RecentNotes() {
|
2024-04-20 15:51:07 -04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
);
|
2022-05-15 09:56:45 -04:00
|
|
|
return (
|
2024-04-20 15:51:07 -04:00
|
|
|
<div className='block'>
|
2024-02-13 18:01:07 -05:00
|
|
|
<h2>Recent Notes</h2>
|
2024-04-20 15:51:07 -04:00
|
|
|
<ul>
|
2024-02-13 18:01:07 -05:00
|
|
|
{notes?.slice(0, 5)
|
2024-04-20 15:51:07 -04:00
|
|
|
.map(({slug, title, mtime}) => {
|
2024-02-13 18:01:07 -05:00
|
|
|
return (
|
2024-12-06 13:52:40 -05:00
|
|
|
<li key={slug} >
|
2024-04-20 15:51:07 -04:00
|
|
|
<Link href={`/notes/${slug}`}>{title}</Link>
|
2024-02-13 18:01:07 -05:00
|
|
|
</li>
|
|
|
|
);
|
2022-05-15 09:56:45 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
{
|
2024-02-13 18:01:07 -05:00
|
|
|
notes.length > 5 &&
|
|
|
|
<Link href='/notes'>More...</Link>
|
2022-05-15 09:56:45 -04:00
|
|
|
}
|
2024-02-13 18:01:07 -05:00
|
|
|
</ul>
|
2024-04-20 15:51:07 -04:00
|
|
|
</div>
|
2022-04-28 12:37:12 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-09-20 00:25:34 -04:00
|
|
|
export default RecentNotes;
|