Skip to content

Instantly share code, notes, and snippets.

@giuseppeg
Created August 19, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseppeg/4ee67df54eabd26193e17b66f1d68229 to your computer and use it in GitHub Desktop.
Save giuseppeg/4ee67df54eabd26193e17b66f1d68229 to your computer and use it in GitHub Desktop.
static async getInitialProps ({ Component, router, ctx }) {
let page = {}
if (Component.getInitialProps) {
page = await Component.getInitialProps(ctx)
}
const basepath = typeof window === 'undefined'
? ''
: location.pathname.slice(0, location.pathname.length - router.route.length).replace(/\/$/, '')
return { page, basepath }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment