diff --git a/packages/next/export/worker.ts b/packages/next/export/worker.ts index eb8734f07119ffe..d02907d004fc806 100644 --- a/packages/next/export/worker.ts +++ b/packages/next/export/worker.ts @@ -332,7 +332,7 @@ export default async function exportPage({ if (serverless) { req.url += (req.url!.includes('?') ? '&' : '?') + 'amp=1' // @ts-ignore - ampHtml = (await renderMethod(req, res, 'export')).html + ampHtml = (await renderMethod(req, res, 'export', undefined, params)).html } else { ampHtml = await renderMethod( req, diff --git a/test/integration/amphtml-ssg/pages/blog/[slug].js b/test/integration/amphtml-ssg/pages/blog/[slug].js index 38f28cd7f387b1b..bff67159ba29513 100644 --- a/test/integration/amphtml-ssg/pages/blog/[slug].js +++ b/test/integration/amphtml-ssg/pages/blog/[slug].js @@ -4,9 +4,10 @@ export const config = { amp: 'hybrid', } -export const getStaticProps = () => { +export const getStaticProps = (ctx) => { return { props: { + slug: (ctx && ctx.params && ctx.params.slug) || null, hello: 'hello', random: Math.random(), }, @@ -18,10 +19,11 @@ export const getStaticPaths = () => ({ fallback: false, }) -export default ({ hello, random }) => ( +export default ({ hello, random, slug }) => ( <>

useAmp: {useAmp() ? 'yes' : 'no'}

{hello}

{random}

+

{slug}

) diff --git a/test/integration/amphtml-ssg/test/index.test.js b/test/integration/amphtml-ssg/test/index.test.js index e7d8f3a4f201dff..51d7ad463764830 100644 --- a/test/integration/amphtml-ssg/test/index.test.js +++ b/test/integration/amphtml-ssg/test/index.test.js @@ -51,6 +51,7 @@ const runTests = (isDev = false) => { const $ = cheerio.load(html) expect($('#use-amp').text()).toContain('no') expect($('#hello').text()).toContain('hello') + expect($('#slug').text()).toContain('post-1') }) it('should load dynamic hybrid SSG/AMP page with trailing slash', async () => { @@ -58,6 +59,7 @@ const runTests = (isDev = false) => { const $ = cheerio.load(html) expect($('#use-amp').text()).toContain('no') expect($('#hello').text()).toContain('hello') + expect($('#slug').text()).toContain('post-1') }) it('should load dynamic hybrid SSG/AMP page with query', async () => { @@ -65,6 +67,7 @@ const runTests = (isDev = false) => { const $ = cheerio.load(html) expect($('#use-amp').text()).toContain('yes') expect($('#hello').text()).toContain('hello') + expect($('#slug').text()).toContain('post-1') }) it('should load a hybrid amp page with query correctly', async () => {