From 173c5c56542548692a6cfa3f8a857a29d3513065 Mon Sep 17 00:00:00 2001 From: Hippo Date: Sun, 6 Oct 2019 17:39:25 +0530 Subject: [PATCH] Detect internal URLs in menu using config.siteUrl This is so that menu items defined in Ghost don't get mistakenly processed as external sites --- src/components/common/Navigation.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/common/Navigation.js b/src/components/common/Navigation.js index d0baf23..59e5bb0 100644 --- a/src/components/common/Navigation.js +++ b/src/components/common/Navigation.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { Link } from 'gatsby' +import config from '../../utils/siteConfig' /** * Navigation component @@ -17,7 +18,9 @@ const Navigation = ({ data, navClass }) => ( {data.map((navItem, i) => { if (navItem.url.match(/^\s?http(s?)/gi)) { return {navItem.label} - } else { + } else if (navItem.url.slice(0, config.siteUrl.length) == config.siteUrl) { + return {navItem.label} + } else{ return {navItem.label} } })}