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-08-12 02:38:42 +02:00
|
|
|
// Don't assign the context value to a variable to save bytes
|
|
|
|
return isInAmpMode(React.useContext(AmpStateContext))
|
2019-04-11 20:59:26 +02:00
|
|
|
}
|