From 5099ba46aa20f71dc083bdc28061b63a6a41f00c Mon Sep 17 00:00:00 2001 From: Vince Picone Date: Fri, 24 Apr 2020 12:42:28 -0500 Subject: [PATCH] fix: nextprev logic with pathPrefix (#823) --- .../src/components/NextPrevious/NextPrevious.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-theme-carbon/src/components/NextPrevious/NextPrevious.js b/packages/gatsby-theme-carbon/src/components/NextPrevious/NextPrevious.js index c4e1e8d19..83af16b00 100644 --- a/packages/gatsby-theme-carbon/src/components/NextPrevious/NextPrevious.js +++ b/packages/gatsby-theme-carbon/src/components/NextPrevious/NextPrevious.js @@ -38,9 +38,7 @@ const useNavigationList = () => { ]; }; -const getTabItems = ({ tabs, location }) => { - const { pathname } = location; - const currentPage = pathname.split('/'); +const getTabItems = ({ tabs, hrefSegments }) => { if (!tabs) { return { prevTabItem: null, @@ -53,7 +51,7 @@ const getTabItems = ({ tabs, location }) => { lower: true, }); const currentTab = - currentPage.filter((item) => item === slug).toString() === slug; + hrefSegments.filter((item) => item === slug).toString() === slug; return { title, slug, @@ -116,7 +114,7 @@ const NextPreviousContainer = (props) => { const { prevTabItem, nextTabItem } = getTabItems({ currentTitle, - location, + hrefSegments, tabs, });