Migrate to Contentlayer2

This commit is contained in:
2025-11-19 21:46:49 +08:00
parent a249a120a5
commit 4c08413936
18 changed files with 1370 additions and 6377 deletions

View File

@@ -10,7 +10,7 @@ interface TocItem {
depth: number;
}
export function PostToc() {
export function PostToc({ onLinkClick }: { onLinkClick?: () => void }) {
const [items, setItems] = useState<TocItem[]>([]);
const [activeId, setActiveId] = useState<string | null>(null);
const listRef = useRef<HTMLDivElement | null>(null);
@@ -87,6 +87,11 @@ export function PostToc() {
url.hash = id;
history.replaceState(null, '', url.toString());
}
// Trigger callback if provided (e.g. to close mobile menu)
if (onLinkClick) {
onLinkClick();
}
};
if (items.length === 0) return null;