Skip to content

Commit

Permalink
fix: next-previous path-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
vpicone committed May 13, 2019
1 parent efa491b commit 720e4d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-theme-carbon/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = themeOptions => {
siteMetadata: {
title: 'Gatsby Theme Carbon',
},
pathPrefix: `/prefix`,
pathPrefix: `/gatsby-theme-carbon`,
plugins: [
`gatsby-plugin-sharp`,
`gatsby-transformer-yaml`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const getName = (category, title) => `${category}${title ? `: ${title}` : ''}`;

const NextPreviousContainer = props => {
const { tabs, location, pageContext = { frontmatter: 'Home' } } = props;
const [navigationList] = useNavigationList();
const [navigationList, pathPrefix] = useNavigationList();
const currentTitle = getTitle(pageContext);

const { prevTabItem, nextTabItem } = getTabItems({
Expand All @@ -106,9 +106,10 @@ const NextPreviousContainer = props => {
});

const getPreviousItem = () => {
const href = location.pathname.replace(pathPrefix, '');
if (prevTabItem) {
return {
to: `${location.pathname.replace(currentTitle, prevTabItem.slug)}`,
to: `${href.replace(currentTitle, prevTabItem.slug)}`,
name: getName(navigationList[navIndex].title, prevTabItem.title),
};
}
Expand Down Expand Up @@ -140,8 +141,9 @@ const NextPreviousContainer = props => {
}

if (nextTabItem && nextTabItem.slug) {
const href = location.pathname.replace(pathPrefix, '');
return {
to: `${location.pathname.replace(currentTitle, nextTabItem.slug)}`,
to: `${href.replace(currentTitle, nextTabItem.slug)}`,
name: getName(navigationList[navIndex].title, nextTabItem.title),
};
}
Expand Down

0 comments on commit 720e4d0

Please sign in to comment.