fix: address early review comments and lint
This commit is contained in:
committed by
Stuart Taylor
parent
65c427a266
commit
7783079af7
@@ -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;
|
||||
|
Reference in New Issue
Block a user