@draftbox-co/gatsby-ghost-novela-theme
Version:
A Gatsby theme plugin for creating blogs from headless Ghost CMS.
23 lines (18 loc) • 607 B
JavaScript
/* eslint-disable */
module.exports = ({ routerProps, prevRouterProps, getSavedScrollPosition }) => {
const currentPosition = getSavedScrollPosition(routerProps.location);
const topOfPage = [0, 0];
if (routerProps.location.action === 'POP' && currentPosition) {
window.scrollTo(...currentPosition);
} else {
window.scrollTo(...topOfPage);
}
// Handling previous path into local storage for "Back" arrow button
if (prevRouterProps) {
window.localStorage.setItem(
'previousPath',
prevRouterProps.location.pathname,
);
}
return false;
};