Files
Slawek KolodziejGitHubTim Neutkenskodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
4238878c17 Make sure that params are properly passed to hybrid amp pages (#17461)
Co-authored-by: Tim Neutkens <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-15 16:03:02 +02:00

30 lines
559 B
JavaScript

import { useAmp } from 'next/amp'
export const config = {
amp: 'hybrid',
}
export const getStaticProps = (ctx) => {
return {
props: {
slug: ctx.params?.slug || null,
hello: 'hello',
random: Math.random(),
},
}
}
export const getStaticPaths = () => ({
paths: ['/blog/post-1', '/blog/post-2'],
fallback: false,
})
export default ({ hello, random, slug }) => (
<>
<p id="use-amp">useAmp: {useAmp() ? 'yes' : 'no'}</p>
<p id="hello">{hello}</p>
<p id="random">{random}</p>
<p id="slug">{slug}</p>
</>
)