fix: address early review comments and lint

This commit is contained in:
Mrugesh Mohapatra
2019-02-18 20:43:41 +05:30
committed by Stuart Taylor
parent 65c427a266
commit 7783079af7
10 changed files with 320 additions and 442 deletions

View File

@@ -1,8 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link as GatsbyLink } from 'gatsby';
const propTypes = {
children: PropTypes.any,
external: PropTypes.bool,
to: PropTypes.string.isRequired
};
const Link = ({ children, to, external, ...other }) => {
if (!external && (/^\/(?!\/)/).test(to)) {
if (!external && /^\/(?!\/)/.test(to)) {
return (
<GatsbyLink to={to} {...other}>
{children}
@@ -16,5 +23,6 @@ const Link = ({ children, to, external, ...other }) => {
</a>
);
};
Link.propTypes = propTypes;
export default Link;