defaultStaticProps.ts 430 B

123456789101112131415161718
  1. import loadIntlMessages from "./loadIntlMessages"
  2. export function withDefaultStaticProps(origin?) {
  3. return async (ctx) => {
  4. const {
  5. props: originProps = {},
  6. revalidate = undefined,
  7. ...originRemaining
  8. } = origin ? await origin(ctx) : {}
  9. return {
  10. props: { intlMessages: await loadIntlMessages(ctx), ...originProps },
  11. revalidate: revalidate || 300,
  12. ...originRemaining,
  13. }
  14. }
  15. }