Limit sidebar to top 5 popular tags and add tag index page

This commit is contained in:
2025-11-17 21:31:39 +08:00
parent 1fc34e2ef6
commit 845be8a6fe
2 changed files with 56 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ import { getAllPostsSorted, getAllTagsWithCount } from '@/lib/posts';
export function RightSidebar() {
const latest = getAllPostsSorted().slice(0, 5);
const tags = getAllTagsWithCount().slice(0, 30);
const tags = getAllTagsWithCount().slice(0, 5);
return (
<aside className="hidden lg:block">
@@ -39,7 +39,7 @@ export function RightSidebar() {
{tags.length > 0 && (
<section className="rounded-xl border bg-white px-4 py-3 text-sm shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-100">
<h2 className="text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400">
</h2>
<div className="mt-2 flex flex-wrap gap-2 text-xs">
{tags.map(({ tag, slug, count }, index) => {
@@ -68,6 +68,14 @@ export function RightSidebar() {
);
})}
</div>
<div className="mt-2 text-right text-[11px]">
<Link
href="/tags"
className="text-slate-500 hover:text-blue-600 dark:text-slate-400 dark:hover:text-blue-400"
>
</Link>
</div>
</section>
)}
</div>