www/components/recent-notes.tsx

34 lines
882 B
TypeScript
Raw Normal View History

2022-04-28 16:37:12 +00:00
import Link from "next/link";
import NotesInfo from '../public/notes.json';
2022-04-28 16:37:12 +00:00
function RecentNotes() {
const notes = Object.entries(NotesInfo).reverse();
2022-05-15 13:56:45 +00:00
return (
<div className='block'>
<h2>Recent Notes</h2>
<ul>
{notes?.slice(0, 5)
.map(([slug, note]: any, i: number) => {
return (
<li
key={i}
>
<Link
href={`/notes/${slug}`}>
{note.title}
</Link>
</li>
);
2022-05-15 13:56:45 +00:00
})
}
{
notes.length > 5 &&
<Link href='/notes'>More...</Link>
2022-05-15 13:56:45 +00:00
}
</ul>
</div>
2022-04-28 16:37:12 +00:00
);
}
export default RecentNotes;