| 
									
										
										
										
											2018-08-23 16:29:26 +01:00
										 |  |  | import PropTypes from 'prop-types'; | 
					
						
							| 
									
										
										
										
											2021-08-02 15:39:40 +02:00
										 |  |  | import React from 'react'; | 
					
						
							| 
									
										
										
										
											2020-12-16 12:39:52 -06:00
										 |  |  | import { I18nextProvider } from 'react-i18next'; | 
					
						
							| 
									
										
										
										
											2021-08-02 15:39:40 +02:00
										 |  |  | import { Provider } from 'react-redux'; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:29:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 12:39:52 -06:00
										 |  |  | import i18n from './i18n/config'; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:29:26 +01:00
										 |  |  | import { createStore } from './src/redux/createStore'; | 
					
						
							| 
									
										
										
										
											2021-07-12 12:35:01 +05:30
										 |  |  | import layoutSelector from './utils/gatsby/layout-selector'; | 
					
						
							| 
									
										
										
										
											2021-01-13 16:12:32 +03:00
										 |  |  | import { getheadTagComponents, getPostBodyComponents } from './utils/tags'; | 
					
						
							| 
									
										
										
										
											2018-10-04 14:47:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:29:26 +01:00
										 |  |  | const store = createStore(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const wrapRootElement = ({ element }) => { | 
					
						
							| 
									
										
										
										
											2020-12-16 12:39:52 -06:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <Provider store={store}> | 
					
						
							|  |  |  |       <I18nextProvider i18n={i18n}>{element}</I18nextProvider> | 
					
						
							|  |  |  |     </Provider> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2018-08-23 16:29:26 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | wrapRootElement.propTypes = { | 
					
						
							|  |  |  |   element: PropTypes.any | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-09-30 11:37:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  | export const wrapPageElement = layoutSelector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-18 17:45:34 +02:00
										 |  |  | export const onRenderBody = ({ | 
					
						
							|  |  |  |   pathname, | 
					
						
							|  |  |  |   setHeadComponents, | 
					
						
							|  |  |  |   setPostBodyComponents | 
					
						
							|  |  |  | }) => { | 
					
						
							| 
									
										
										
										
											2021-01-13 16:12:32 +03:00
										 |  |  |   setHeadComponents(getheadTagComponents()); | 
					
						
							|  |  |  |   setPostBodyComponents(getPostBodyComponents(pathname)); | 
					
						
							| 
									
										
										
										
											2018-09-30 11:37:19 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-01-27 16:47:01 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const onPreRenderHTML = ({ | 
					
						
							|  |  |  |   getHeadComponents, | 
					
						
							|  |  |  |   replaceHeadComponents | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   const headComponents = getHeadComponents(); | 
					
						
							|  |  |  |   headComponents.sort((x, y) => { | 
					
						
							|  |  |  |     if (x.key === 'bootstrap-min-preload' || x.key === 'bootstrap-min') { | 
					
						
							|  |  |  |       return -1; | 
					
						
							|  |  |  |     } else if (y.key === 'bootstrap-min-preload' || y.key === 'bootstrap-min') { | 
					
						
							|  |  |  |       return 1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   replaceHeadComponents(headComponents); | 
					
						
							|  |  |  | }; |