UNPKG

@aamodtgroup/agtech

Version:

A starter theme for Frontity from AG Tech

39 lines (34 loc) 887 B
import { connect, useConnect } from "frontity"; import Link from "@frontity/components/link"; /** * The MarsLink component, which is a wrapper on top of the {@link Link} * component. * * @param props - It accepts the same props than the {@link Link} component. * * @example * ```js * <MarsLink link="/some-post"> * <div>Some Post</div> * </MarsLink> * ``` * * @returns A {@link Link} component, which returns an HTML anchor element. */ const MarsLink = ({ children, ...props }) => { const { state, actions } = useConnect(); /** * A handler that closes the mobile menu when a link is clicked. */ const onClick = () => { if (state.theme.isMobileMenuOpen) { actions.theme.closeMobileMenu(); } }; return ( <Link {...props} onClick={onClick}> {children} </Link> ); }; export default connect(MarsLink, { injectProps: false });