diff --git a/gatsby-browser.js b/gatsby-browser.js index e1b7b01..ec77758 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -15,8 +15,20 @@ import './src/components/Footer/Footer.scss' import 'prismjs/themes/prism-tomorrow.css' import 'prismjs/plugins/line-numbers/prism-line-numbers.css' + import { ThemeProvider } from "./src/context/ThemeContext" export const wrapRootElement = ({ element }) => ( {element} -) \ No newline at end of file +) + +export const shouldUpdateScroll = ({ + routerProps: { location } +}) => { + const { pathname } = location + const scrollToTopRoutes = [`/`, `/about`, '/contacts', '/books', '/articles'] + + if (scrollToTopRoutes.indexOf(pathname) !== -1) window.scrollTo(0, 0) + + return false +} \ No newline at end of file diff --git a/src/components/Articles/Search/Search.js b/src/components/Articles/Search/Search.js index b2ec79d..35bd61e 100644 --- a/src/components/Articles/Search/Search.js +++ b/src/components/Articles/Search/Search.js @@ -6,7 +6,7 @@ const Search = ({ allArticles, filterArticles, articlesLength, resultsLength, qu const handleInput = e => { const query = e.target.value if (query === '') { - navigate('/articles') + navigate('/articles/') setQuery('') return null }