a844b26250
- 新增 FullscreenTransitionProvider + RouteTransitionOverlay: cover(0.8s b1 遮罩 wipe) → push → reveal 状态机(原 73475/34841 移植), Work 卡片与详情页链接全部走 startNavigation(同路径点击回顶部) - 新增 app/work/[slug] 详情页:content/workArticles.ts 从原站 6 个详情页 1:1 提取(MDX 文章+Metadata+iframe 预览+Links),/2026 锁定时渲染解锁屏 - 新增 CustomScrollbar:桌面右缘 SVG 轨道+拖拽 thumb(188 轨道/min20)、 点击跳转、2s 自动隐藏;移动端底部进度环回顶按钮(原 72443 移植) - BackgroundGrid 重写为原版算法(3 行十字/12px 缺口/12 列内分数纵线, 主页 loading 时隐藏其余时间常显);层叠改为原版结构:canvas z-auto 最前 → grid z-20 → DOM 内容,移除各 section 的 z-30 - 修复 BGM:持久化开启时首次手势自动恢复播放(autoplay 策略被拒后 pointerdown/keydown/touchstart 重试),enabled 闭包改用 ref - 页脚邮箱改为 chenchun@virtheart.com
271 lines
9.7 KiB
TypeScript
271 lines
9.7 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* Work detail pages — /work/[slug] rendering the original MDX article
|
|
* markup 1:1 (from https://haoqi.design/reunimos et al.):
|
|
*
|
|
* <div class="fixed inset-0 w-full h-full">
|
|
* <div class="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
|
* <article data-mdx-article class="mx-auto px-6 py-18 lg:py-24 w-full
|
|
* max-w-[880px] text-l1">
|
|
* <header class="pt-[10vh]"> h1 + date + hr + year </header>
|
|
* <div class="[&_p+p]:mt-3 …"> blocks </div>
|
|
* </article>
|
|
*
|
|
* Content comes from content/workArticles.ts (extracted from the live
|
|
* pages). Passcode-protected scopes (/2026) render the unlock screen when
|
|
* locked, exactly like the original.
|
|
*/
|
|
import { Suspense, useMemo } from "react";
|
|
import Link from "next/link";
|
|
import { useParams } from "next/navigation";
|
|
import {
|
|
WORK_ARTICLES,
|
|
type ArticleBlock,
|
|
type InlineSeg,
|
|
} from "@/content/workArticles";
|
|
import { usePasscodeAllowed } from "@/components/dom/PasscodeAccess";
|
|
import { useRouteTransitionController } from "@/lib/routeTransition";
|
|
import { PasscodeUnlockScreen } from "@/components/dom/PasscodeUnlockScreen";
|
|
import { buildPasscodeUnlockHref, primaryPasscodePath, scopeToPath } from "@/lib/passcode";
|
|
import CustomScrollbar from "@/components/dom/CustomScrollbar";
|
|
|
|
const PROSE_CLASS =
|
|
"[&_p+p]:mt-3 [&_p]:mb-0 text-l2 [&_p]:text-sm [&_p]:text-l1 [&_p]:leading-relaxed lg:[&_p]:text-base";
|
|
|
|
function Inline({ segs }: { segs: InlineSeg[] }) {
|
|
return (
|
|
<>
|
|
{segs.map((s, i) =>
|
|
s.t === "link" ? (
|
|
<a
|
|
key={i}
|
|
href={s.href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="inline text-l1 underline underline-offset-[0.08em] decoration-solid decoration-(--label-3) transition-[text-decoration-color] duration-150 ease-out lg:[@media(hover:hover)]:hover:decoration-(--label-1)"
|
|
>
|
|
{s.v}
|
|
</a>
|
|
) : (
|
|
<span key={i}>{s.v}</span>
|
|
)
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
function Block({ block }: { block: ArticleBlock }) {
|
|
switch (block.type) {
|
|
case "p":
|
|
return (
|
|
<p>
|
|
<Inline segs={block.segs} />
|
|
</p>
|
|
);
|
|
case "h2":
|
|
return <h2 className="mt-8 font-bold text-xl! text-l1">{block.text}</h2>;
|
|
case "h3":
|
|
return <h3 className="mt-6 font-bold text-lg! text-l1">{block.text}</h3>;
|
|
case "img":
|
|
// eslint-disable-next-line @next/next/no-img-element -- original uses plain img with cursor-zoom-in
|
|
return (
|
|
<img
|
|
src={block.src}
|
|
alt=""
|
|
crossOrigin="anonymous"
|
|
loading="lazy"
|
|
decoding="async"
|
|
className="block w-full h-auto cursor-zoom-in select-none border border-line bg-[rgba(var(--label-d),0.05)]"
|
|
/>
|
|
);
|
|
case "hr":
|
|
return <hr className="my-8 h-px w-full border-0 bg-line" />;
|
|
case "list":
|
|
return block.ordered ? (
|
|
<ol className="list-decimal my-0 pl-5 space-y-0">
|
|
{block.items.map((li, i) => (
|
|
<li key={i} className="text-l1 leading-relaxed">
|
|
<Inline segs={li} />
|
|
</li>
|
|
))}
|
|
</ol>
|
|
) : (
|
|
<ul className="list-disc my-0 pl-5 space-y-0">
|
|
{block.items.map((li, i) => (
|
|
<li key={i} className="text-l1 leading-relaxed">
|
|
<Inline segs={li} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
);
|
|
case "quote":
|
|
return (
|
|
<blockquote className="border-l-4 border-(--selection-bg) pl-4 text-l2">
|
|
{block.items.map((q, i) => (
|
|
<p key={i} className="text-l2">
|
|
{q}
|
|
</p>
|
|
))}
|
|
</blockquote>
|
|
);
|
|
case "code":
|
|
return (
|
|
<pre className="my-4 overflow-x-auto rounded bg-[rgba(var(--label-d),0.08)] p-3 font-mono text-[0.9em] text-l1">
|
|
<code>{block.text}</code>
|
|
</pre>
|
|
);
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function Article({ slug }: { slug: string }) {
|
|
const article = WORK_ARTICLES[slug];
|
|
if (!article) {
|
|
return (
|
|
<div className="fixed inset-0 w-full h-full">
|
|
<div className="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
|
<article className="mx-auto px-6 py-18 lg:py-24 w-full max-w-[880px] text-l1">
|
|
<header className="pt-[10vh]">
|
|
<h1 className="font-bold text-3xl! text-l1 lg:text-5xl! leading-tight tracking-tight">
|
|
404
|
|
</h1>
|
|
<p className="mt-1 text-l2! text-sm! lg:text-base! leading-relaxed">
|
|
No article for this work yet.
|
|
</p>
|
|
<div className="mt-2 border-line border-b" />
|
|
<p className="pt-3 text-l2! text-sm! lg:text-base! leading-relaxed">
|
|
<Link className="underline underline-offset-4" href="/">
|
|
← Home
|
|
</Link>
|
|
</p>
|
|
</header>
|
|
</article>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
return (
|
|
<div className="fixed inset-0 w-full h-full">
|
|
<div className="w-full h-full overflow-y-auto overscroll-contain no-scrollbar">
|
|
<article
|
|
data-mdx-article="true"
|
|
className="mx-auto px-6 py-18 lg:py-24 w-full max-w-[880px] text-l1"
|
|
>
|
|
<header className="pt-[10vh]">
|
|
<h1 className="font-bold text-3xl! text-l1 lg:text-5xl! leading-tight tracking-tight" style={{ fontVariationSettings: '"wdth" 120' }}>
|
|
{article.title}
|
|
</h1>
|
|
<p className="mt-1 tabular-nums text-l2! text-sm! lg:text-base! leading-relaxed">
|
|
{article.date}
|
|
</p>
|
|
<div className="mt-2 border-line border-b" />
|
|
<p className="pt-3 text-l2! text-sm! lg:text-base! leading-relaxed">
|
|
{article.year}
|
|
</p>
|
|
</header>
|
|
<div className={PROSE_CLASS}>
|
|
{article.blocks.map((b, i) => (
|
|
<Block key={i} block={b} />
|
|
))}
|
|
{article.iframe && (
|
|
<iframe
|
|
width="840"
|
|
height="600"
|
|
src={article.iframe.src}
|
|
title={article.iframe.title}
|
|
allowFullScreen
|
|
className="mt-8 w-full border-0"
|
|
/>
|
|
)}
|
|
</div>
|
|
{article.meta && (
|
|
<footer
|
|
data-mdx-footer="true"
|
|
className="bg-[rgba(var(--label-d),0.03)] mt-16 p-4 lg:p-6 rounded-xl"
|
|
>
|
|
<div className="mb-5 font-sans font-semibold text-l1 text-base">
|
|
Metadata
|
|
</div>
|
|
<dl className="gap-x-6 gap-y-6 grid grid-cols-2 lg:grid-cols-3">
|
|
{article.meta.map(([dt, dd]) => (
|
|
<div key={dt} className="flex flex-col gap-1.5">
|
|
<dt className="font-sans font-semibold text-l1 text-sm">{dt}</dt>
|
|
<dd>
|
|
<span className="font-mono tabular-nums text-l2 text-sm">{dd}</span>
|
|
</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
<div className="my-6 border-line border-t border-dashed" />
|
|
<div className="gap-x-6 gap-y-4 grid grid-cols-2 lg:grid-cols-3">
|
|
<div className="hidden lg:block font-sans font-semibold text-l1 text-sm">
|
|
Links
|
|
</div>
|
|
<div className="flex flex-col items-start gap-1 font-mono">
|
|
<DetailNavLink href="/">Home</DetailNavLink>
|
|
<DetailNavLink href="/">Work</DetailNavLink>
|
|
<DetailNavLink href="/">Contact</DetailNavLink>
|
|
</div>
|
|
<div className="flex flex-col items-start gap-1 font-mono">
|
|
{["Twitter/X", "Figma", "GitHub"].map((label) => (
|
|
<a
|
|
key={label}
|
|
href="#"
|
|
className="relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-transparent before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-l1 inline-block -mx-1 px-1 py-0.5 text-l2 lg:hover:text-l1 text-sm transition-colors"
|
|
>
|
|
{label}
|
|
</a>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
)}
|
|
</article>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function DetailNavLink({ href, children }: { href: string; children: string }) {
|
|
const { startNavigation } = useRouteTransitionController();
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={() => startNavigation(href)}
|
|
className="relative before:content-[''] before:absolute before:inset-0 before:border-2 before:border-dotted before:border-transparent before:pointer-events-none before:transition-colors before:duration-200 lg:hover:before:border-l1 inline-block -mx-1 px-1 py-0.5 text-l2 lg:hover:text-l1 text-sm transition-colors text-left cursor-pointer"
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
function WorkDetailInner() {
|
|
const params = useParams<{ slug: string }>();
|
|
const raw = String(params?.slug ?? "");
|
|
// /work/2026 is the passcode-protected scope; the others map back to the
|
|
// original slugs (/work/reunimos → content key "/reunimos").
|
|
const slug = `/${raw}`;
|
|
const allowed = usePasscodeAllowed(slug);
|
|
if (!allowed) {
|
|
// Protected scope (e.g. /2026) renders the unlock screen in place,
|
|
// exactly like the original detail route.
|
|
return <PasscodeUnlockScreen scope={slug} returnTo={slug} />;
|
|
}
|
|
return (
|
|
<>
|
|
<Article slug={slug} />
|
|
<CustomScrollbar />
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default function WorkDetailPage() {
|
|
return (
|
|
<Suspense fallback={null}>
|
|
<WorkDetailInner />
|
|
</Suspense>
|
|
);
|
|
}
|