import React from 'react'; /** * Mock for Next.js Link component * Converts Next.js Link to a standard anchor tag for Preview.js */ const NextLinkMock = ({ href, as, replace, scroll, shallow, passHref, prefetch, locale, children, className, style, onClick, ...rest }) => { // Handle click events const handleClick = (e) => { e.preventDefault(); console.log('Link clicked:', { href, as }); // Call original onClick if provided if (onClick) { onClick(e); } }; // If children is a function, call it with the link props if (typeof children === 'function') { return children({ href: typeof href === 'object' ? href.pathname || '/' : href, className, style, onClick: handleClick, ...rest }); } // If children is a single child element, clone it with link props if (React.isValidElement(children)) { return React.cloneElement(children, { href: typeof href === 'object' ? href.pathname || '/' : href, onClick: handleClick, className: children.props.className || className, style: { ...style, ...children.props.style }, ...rest }); } // Default: render as anchor tag return ( {children} ); }; export default NextLinkMock;