Static generation of AMP pages #13283
Unanswered
expertdeveloperit
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys,
I am building an app using amp and next js.
I want to develop amp pages using staticGeneration method of nextjs i.e. by using getStaticProps() and getStaticPaths();
If i use these methods in amp only page i am not able to use props in amp page. Which is causing an issue. Please help me huys it's really urgent.
`import React from "react";
import { SkipNavContent } from "@reach/skip-nav";
import Page from "../../../../components/page";
import SocialMeta from "../../../../components/social-meta";
import PropertyDetail from "../../../../components/PropertyDetail";
import {
// getCities,
// getCityListingsSnapshot,
fetchDetails,
} from "../../../../lib/datahelpers";
export const config = { amp: true };
export default (props) => {
console.log('props', props)
return (
<>
<PropertyDetail property={props.property} {...props} />
</>
);
};
export async function getStaticProps(context) {
const id = context.params.Address.split('-')
const data = await fetchDetails(id[id.length - 1]);
return { props: { property: data.length ? data[0] : null }}
}
// This function gets called at build time
export async function getStaticPaths() {
const city_name = "edison";
return {
paths: [
{
params: {
City: city_name,
Address: "static_address",
},
},
],
// Enable statically generating additional pages
fallback: true,
};
}`
This is my code for ampOnly page. I can see the console in my terminal but when accessing not able to do so.
Beta Was this translation helpful? Give feedback.
All reactions