Skip to content

Commit ba3bc64

Browse files
committed
refactor(profile): 调整 profile 页版式,避免文档多的用户下滑过久
- 右侧 Bento 小卡区只保留 projects / papers,DOC 卡片抽出去 - 活跃度热力图从页底提到 Bento 之后立即显示(视觉重点前置) - 新增 SEC. DOCS 独立 section 放页尾,紧凑列表(每行 ~48px 而非 180px 小卡) - 默认只显示前 10 篇,超过的用 <details> 折叠"展开剩余 N 篇" 旧版顺序:Identity(bio/stats)+DOC 卡(8 条) → Heatmap → Repos 新版顺序:Identity(bio/stats)+projects/papers → Heatmap → Repos → Docs 列表(折叠) 文档特别多的用户(本作者 44 条)现在热力图和 repos 一屏可见,docs 列表放最后折叠。
1 parent fc864c5 commit ba3bc64

1 file changed

Lines changed: 73 additions & 20 deletions

File tree

app/u/[username]/page.tsx

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -392,29 +392,15 @@ export default async function UserProfilePage({ params }: Param) {
392392
href={sanitizeExternalUrl(p.url) ?? undefined}
393393
/>
394394
))}
395-
{docs.slice(0, 8).map((doc, idx) => (
396-
<ProfileCard
397-
key={`doc-${doc.id}`}
398-
kind="DOC"
399-
index={idx + 1}
400-
title={doc.title}
401-
meta={`文档 · ${doc.id.slice(0, 8)}`}
402-
summary={doc.url}
403-
detail={`标题:${doc.title}\n路径:${doc.url}`}
404-
href={doc.url}
405-
/>
406-
))}
407-
{projects.length === 0 &&
408-
papers.length === 0 &&
409-
docs.length === 0 && (
410-
<div className="col-span-full border border-dashed border-[var(--foreground)] p-10 text-center text-neutral-500 font-mono text-sm">
411-
该用户还没有填写 projects / papers,也没有文档贡献记录。
412-
</div>
413-
)}
395+
{projects.length === 0 && papers.length === 0 && (
396+
<div className="col-span-full border border-dashed border-[var(--foreground)] p-10 text-center text-neutral-500 font-mono text-sm">
397+
该用户还没有填写 projects / papers。
398+
</div>
399+
)}
414400
</div>
415401
</div>
416402

417-
{/* 活跃度热力图:Bento 下方独立一行全宽,仅当有贡献数据时显示 */}
403+
{/* 活跃度热力图:提到 Bento 之后立即显示,让数据可视化先于冗长的列表 */}
418404
{Object.keys(dailyCounts).length > 0 && (
419405
<div className="mt-12">
420406
<ActivityHeatmap dailyCounts={dailyCounts} />
@@ -425,13 +411,80 @@ export default async function UserProfilePage({ params }: Param) {
425411
<div className="mt-12">
426412
<GithubRepos identifier={username} />
427413
</div>
414+
415+
{/* 文档贡献列表:放最底部,紧凑列表形式(每行 ~48px),避免 docs 多的用户把页面顶得很长。
416+
超过 10 条时用 <details> 折叠,默认只显示前 10 */}
417+
{docs.length > 0 && (
418+
<section className="mt-12 border border-[var(--foreground)] p-6 lg:p-8 flex flex-col gap-4">
419+
<div className="flex items-baseline justify-between gap-3 flex-wrap border-b border-[var(--foreground)] pb-3">
420+
<div>
421+
<div className="font-mono text-[10px] uppercase tracking-widest text-neutral-500">
422+
SEC. DOCS · 007
423+
</div>
424+
<h3 className="font-serif text-xl font-black uppercase mt-1 text-[var(--foreground)]">
425+
贡献过的文档
426+
</h3>
427+
</div>
428+
<div className="font-mono text-[10px] text-neutral-500">
429+
{docs.length} 篇 · 合计 {commits.toLocaleString()} commits
430+
</div>
431+
</div>
432+
<ol className="flex flex-col">
433+
{docs.slice(0, 10).map((doc, idx) => (
434+
<DocRow key={doc.id} idx={idx + 1} doc={doc} />
435+
))}
436+
</ol>
437+
{docs.length > 10 && (
438+
<details className="flex flex-col">
439+
<summary className="font-mono text-[10px] uppercase tracking-widest text-[#CC0000] cursor-pointer hover:underline py-2">
440+
展开剩余 {docs.length - 10} 篇 ↓
441+
</summary>
442+
<ol className="flex flex-col mt-2">
443+
{docs.slice(10).map((doc, idx) => (
444+
<DocRow key={doc.id} idx={idx + 11} doc={doc} />
445+
))}
446+
</ol>
447+
</details>
448+
)}
449+
</section>
450+
)}
428451
</div>
429452
</main>
430453
<Footer />
431454
</>
432455
);
433456
}
434457

458+
/** 紧凑单行文档条目 */
459+
function DocRow({
460+
idx,
461+
doc,
462+
}: {
463+
idx: number;
464+
doc: { id: string; title: string; url: string };
465+
}) {
466+
const safe = sanitizeExternalUrl(doc.url);
467+
return (
468+
<li className="flex items-baseline gap-3 border-t border-[var(--foreground)]/20 first:border-t-0 py-2 group">
469+
<span className="font-mono text-[10px] text-neutral-400 w-6 shrink-0">
470+
{String(idx).padStart(2, "0")}
471+
</span>
472+
{safe ? (
473+
<Link
474+
href={safe}
475+
className="flex-1 font-serif text-sm text-[var(--foreground)] truncate group-hover:text-[#CC0000] transition-colors"
476+
>
477+
{doc.title}
478+
</Link>
479+
) : (
480+
<span className="flex-1 font-serif text-sm text-neutral-400 truncate">
481+
{doc.title}
482+
</span>
483+
)}
484+
</li>
485+
);
486+
}
487+
435488
function Stat({ label, value }: { label: string; value: number }) {
436489
return (
437490
<div>

0 commit comments

Comments
 (0)