2019-02-14 16:22:57 +01:00
|
|
|
import React from 'react'
|
2019-06-27 16:22:24 +02:00
|
|
|
import { AmpStateContext } from './amp-context'
|
2019-04-11 20:59:26 +02:00
|
|
|
|
2019-06-27 16:22:24 +02:00
|
|
|
export function isInAmpMode({
|
|
|
|
ampFirst = false,
|
2019-05-29 13:57:26 +02:00
|
|
|
hybrid = false,
|
|
|
|
hasQuery = false,
|
2019-04-11 20:59:26 +02:00
|
|
|
} = {}) {
|
2019-06-27 16:22:24 +02:00
|
|
|
return ampFirst || (hybrid && hasQuery)
|
2019-04-11 20:59:26 +02:00
|
|
|
}
|
2019-02-14 16:22:57 +01:00
|
|
|
|
|
|
|
export function useAmp() {
|
2019-06-27 16:22:24 +02:00
|
|
|
const ampState = React.useContext(AmpStateContext)
|
2019-04-11 20:59:26 +02:00
|
|
|
// un-comment below to not be considered AMP in dirty mode
|
2019-06-27 16:22:24 +02:00
|
|
|
return isInAmpMode(ampState) // && ampMode.hasQuery
|
2019-04-11 20:59:26 +02:00
|
|
|
}
|