Skip to content
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

Reduce verbosity of getStaticProps #703

Closed
janus-reith opened this issue Jul 14, 2020 · 0 comments
Closed

Reduce verbosity of getStaticProps #703

janus-reith opened this issue Jul 14, 2020 · 0 comments

Comments

@janus-reith
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants