Next.js
0
Вклад в тег
async function withHost(getStaticPropsData) {
const getStaticProps = async (ctx) => {
const response = await getHost(ctx.params.host);
const gspData = await getStaticPropsData(ctx);
return {
props: { host: response.data, ...gpsData.props }
}
};
const getStaticPaths = async () => {
const response = await ServerCache.get("hosts");
return {
paths: response.data.map(...),
fallback: "blocking"
};
}
return { getStaticPaths, getStaticProps };
};
// index.tsx
export const { getStaticPaths, getStaticProps } = withHost(() => ({
props: {}
}))
export const getStaticProps = withHost(() => ({
props: {}
}))
export const getStaticPaths = getHostsPaths();