feat: 详情页 MDX 组件 1:1(目录/锚点/代码块/页脚)与首页层叠修复
- 详情页补齐原站 MDX 组件:左侧目录(2xl 固定定位、滚动高亮 top≤96、 点击平滑滚动)、标题锚点(hover #、点击复制链接 + replaceState)、 代码块(语言标签 + COPY/COPIED + 原站 prism token HTML 按行号渲染, --code-* 配色变量)、页脚 Metadata(实时视口尺寸 / 正文字符数)与 Work/Contact 按钮(sessionStorage hq:pendingScrollAnchor → 首页过渡后 滚动到对应区块,SmoothScroller 消费) - content/workArticles.ts 重新提取:内联 strong/em/code 片段、标题 id、 代码块语言 + 高亮 HTML + 纯文本(bs4 全量解析 6 篇文章) - 详情页不再显示十字网格(BackgroundGrid 按 pathname 门控,置于全部 hooks 之后避免 hook 数量变化崩溃) - 首页层叠修复:WebGL 容器改为原站的 top-0 left-0 -z-1 fixed(此前 z-auto fixed 按 CSS 绘制顺序盖住 banner 文案与作品说明文字),footer 改为原站的 z-10 relative,body 背景移至 html 根节点(否则普通流 body 背景会盖住 -z-1 场景)
This commit is contained in:
@@ -86,6 +86,13 @@ export default function BackgroundGrid() {
|
||||
return { verticalPath, horizontalPath, crossPath };
|
||||
}, [w, h]);
|
||||
|
||||
// The original mounts this grid in the home route tree only — detail
|
||||
// pages (…/reunimos, …/wasm_design_utils) show no crosshair at all.
|
||||
// NOTE: placed after every hook — this component persists in the root
|
||||
// layout, and an early return before useMemo changes the hook count on
|
||||
// route change ("Rendered more hooks than during the previous render").
|
||||
if (pathname !== '/') return null;
|
||||
|
||||
if (loadingGate) return null;
|
||||
|
||||
return (
|
||||
|
||||
@@ -35,7 +35,7 @@ export default function FooterSection() {
|
||||
<footer
|
||||
id="contact"
|
||||
data-section="footer"
|
||||
className="relative flex flex-col justify-center p-6 lg:p-16 w-full h-dvh lg:h-screen pointer-events-none"
|
||||
className="z-10 relative flex flex-col justify-center p-6 lg:p-16 w-full h-dvh lg:h-screen pointer-events-none"
|
||||
>
|
||||
<div
|
||||
className="gap-2 grid grid-cols-12 font-bold text-[7.2svw] lg:text-[6svw] 2xl:text-[5svw] xl:text-[5.6svw] uppercase leading-none"
|
||||
|
||||
@@ -56,6 +56,22 @@ export default function SmoothScroller() {
|
||||
requestAnimationFrame(() => window.scrollTo(0, 0));
|
||||
};
|
||||
resetScroll();
|
||||
|
||||
// Pending anchor from a detail page (original module 54450: the
|
||||
// footer "Work"/"Contact" buttons store the anchor in sessionStorage
|
||||
// and navigate "/" through the transition; the home scroller then
|
||||
// smooth-scrolls to it).
|
||||
const pendingAnchor = sessionStorage.getItem('hq:pendingScrollAnchor');
|
||||
if (pendingAnchor) {
|
||||
sessionStorage.removeItem('hq:pendingScrollAnchor');
|
||||
const target = document.querySelector(pendingAnchor);
|
||||
if (target) {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||
lenis.scrollTo(target as HTMLElement, { lerp: 0.1 });
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const onPageShow = (e: PageTransitionEvent) => {
|
||||
if (e.persisted) resetScroll();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user