-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSG with fallback doesn't generate AMP page dynamically #14256
Comments
This is a memo to workaround the issue: IMO, we should avoid using Instead of using like: pages/[slug]/index.jsx import { useAmp } from "next/amp";
import Head from "next/head";
export default (props) => {
const isAmp = useAmp();
return (
<div>
<Head>
<link rel="canonical" href={`https://example.com/${props.slug}`} />
{!isAmp && (
<link rel="amphtml" href={`https://example.com/${props.slug}/amp`} />
)}
</Head>
{props.slug}
</div>
);
};
export const getStaticProps = async (ctx) => {
return {
props: {
slug: ctx.params.slug,
},
};
};
export const getStaticPaths = async () => {
return { paths: [{ params: { slug: "foo" } }], fallback: true };
}; pages/[slug]/amp.jsx import Original from "./index";
export { getStaticPaths, getStaticProps } from "./index";
export const config = { amp: true };
export default Original; |
Hello! Can I work in this issue? |
I followed the workaround suggested but could not get AMP to load the page dynamically. I used
|
Would love to take this up . Looking for some |
AMP will require you use |
@Timer I'm using |
Bug report
Describe the bug
fallback: true
andamp: "hybrid"
are used together, the paths not specified ingetStaticPaths
have an invalid href in<link rel="amphtml">
tag.pages/[slug].jsx
and the user visits/bar
, the<link rel="amphtml">
tag will refer to/[slug].amp
.To Reproduce
https://github.com/wawoon/next-amp-ssg-fallback-reproduce
pages/[slug]/index.jsx
※ caution: When you add
unstable_revalidate
to getStaticProps, the href of<link rel="amphtml">
is overwritten while regeneration by #14251When the user visits
http://localhost:3000/bar
,bar
is not specified ingetStaticPaths
, the href of<link rel="amphtml">
refers to/[slug].amp
. And this/[slug].amp
is invalid url.Expected behavior
/bar
should have correct amp page path, even when the path is not included ingetStaticPaths
./bar
should be generated usinggetStaticProps
dynamically.Screenshots
System information
Additional context
.amp
with?amp=1
#14251 which is related with amp page with SSG.The text was updated successfully, but these errors were encountered: