amp fixes

This commit is contained in:
Sergey Yarkov 2020-08-17 12:48:05 +03:00
parent 616945a627
commit 0d79c02440
2 changed files with 7 additions and 3 deletions

View File

@ -31,7 +31,7 @@ export const shouldUpdateScroll = ({ routerProps: { location } }) => {
export const wrapPageElement = ({ element, props }) => { export const wrapPageElement = ({ element, props }) => {
const { location: { pathname } } = props const { location: { pathname } } = props
pathname.includes('/amp/') ? props.amp = true : props.amp = false pathname.match(/article\/.*\/amp/) !== null ? props.amp = true : props.amp = false
return <Layout {...props}>{element}</Layout> return <Layout {...props}>{element}</Layout>
} }

View File

@ -39,13 +39,17 @@ const OnDark = () => {
) )
} }
export const onRenderBody = ({ setPreBodyComponents }) => { export const onRenderBody = ({ pathname, setPreBodyComponents }) => {
if (pathname.match(/article\/.*\/amp/) !== null) {
return
}
setPreBodyComponents(<OnDark key="isDarkTheme" />) setPreBodyComponents(<OnDark key="isDarkTheme" />)
} }
export const wrapPageElement = ({ element, props }) => { export const wrapPageElement = ({ element, props }) => {
const { location: { pathname } } = props const { location: { pathname } } = props
pathname.includes('/amp/') ? props.amp = true : props.amp = false pathname.match(/article\/.*\/amp/) !== null ? props.amp = true : props.amp = false
return <Layout {...props}>{element}</Layout> return <Layout {...props}>{element}</Layout>
} }