Open
Description
Bug report
Describe the bug
- When SSG with
fallback: true
andamp: "hybrid"
are used together, the paths not specified ingetStaticPaths
have an invalid href in<link rel="amphtml">
tag.- For example, when there is a
pages/[slug].jsx
and the user visits/bar
, the<link rel="amphtml">
tag will refer to/[slug].amp
.
- For example, when there is a
To Reproduce
https://github.com/wawoon/next-amp-ssg-fallback-reproduce
pages/[slug]/index.jsx
export default (props) => {
return <div>slug: {props.slug}</div>;
};
export const config = {
amp: "hybrid",
};
export const getStaticProps = async (ctx) => {
return {
props: {
slug: ctx.params.slug,
},
};
};
export const getStaticPaths = async () => {
return { paths: [{ params: { slug: "foo" } }], fallback: true };
};
※ caution: When you add unstable_revalidate
to getStaticProps, the href of <link rel="amphtml">
is overwritten while regeneration by #14251
When the user visits http://localhost:3000/bar
, bar
is not specified in getStaticPaths
, the href of <link rel="amphtml">
refers to /[slug].amp
. And this /[slug].amp
is invalid url.
Expected behavior
- The
/bar
should have correct amp page path, even when the path is not included ingetStaticPaths
. - The amp version of
/bar
should be generated usinggetStaticProps
dynamically.
Screenshots
System information
- macOS
- Chrome
- Next: 9.4.5-canary.12
- Node: v12.14.1
Additional context
- I have recently created Incremental Static Regeneration replaces
.amp
with?amp=1
#14251 which is related with amp page with SSG.