import React from 'react'; import PropTypes from 'prop-types'; import { CertificationLayout, DefaultLayout } from '../../src/components/layouts'; import FourOhFourPage from '../../src/pages/404'; export default function layoutSelector({ element, props }) { const { location: { pathname } } = props; if (element.type === FourOhFourPage) { return {element}; } if (/^\/certification(\/.*)*/.test(pathname)) { return ( {element} ); } if (/^\/guide(\/.*)*/.test(pathname)) { console.log('Hitting guide for some reason. Need a redirect.'); } const splitPath = pathname.split('/'); const splitPathThree = splitPath.length > 2 ? splitPath[3] : ''; const isNotSuperBlockIntro = splitPath.length > 3 && splitPathThree.length > 1; if (/^\/learn(\/.*)*/.test(pathname) && isNotSuperBlockIntro) { return ( {element} ); } if (/^\/donation(\/.*)*|^\/$|^\/donate(\/.*)*/.test(pathname)) { return ( {element} ); } return {element}; } layoutSelector.propTypes = { element: PropTypes.any, location: PropTypes.objectOf({ pathname: PropTypes.string }), props: PropTypes.any };