diff --git a/gatsby-browser.js b/gatsby-browser.js
index 2acf0ab..2a3a6d9 100644
--- a/gatsby-browser.js
+++ b/gatsby-browser.js
@@ -31,7 +31,7 @@ export const shouldUpdateScroll = ({ routerProps: { location } }) => {
export const wrapPageElement = ({ element, 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 {element}
}
diff --git a/gatsby-ssr.js b/gatsby-ssr.js
index 8ba0fdb..a33376c 100644
--- a/gatsby-ssr.js
+++ b/gatsby-ssr.js
@@ -39,13 +39,17 @@ const OnDark = () => {
)
}
-export const onRenderBody = ({ setPreBodyComponents }) => {
+export const onRenderBody = ({ pathname, setPreBodyComponents }) => {
+ if (pathname.match(/article\/.*\/amp/) !== null) {
+ return
+ }
+
setPreBodyComponents()
}
export const wrapPageElement = ({ element, 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 {element}
}