Reduce verbosity of getStaticProps
janus-reith opened this issue · 0 comments
janus-reith commented
Summary description
We currently need to include getStaticProps
in every page to fetch data on the server when creating a static page.
Instead, I tried to put that function and just reexport it per page, and can confirm that this works.
On a page this would just look like this:
import getStaticProps from "staticUtils/pageHelpers/getDefaultStaticProps";
export { getStaticProps };
TBD: We could create multiple functions similar to getDefaultStaticProps which include other specific fetches, or make a more sophisticated approach where you don't just reexport getStaticProps
, but call that helper with a list of requirements and it returns the proper getStaticProps
function.
Rationale for why this feature is necessary
There is a lot of duplication for getStaticProps, as most pages will fetch the same data.
Expected use cases
Used on every page in the storefront