Migrate to Contentlayer2
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user