Commit 2796c08e authored by Arunoda Susiripala's avatar Arunoda Susiripala

Fix '/' page serving issue.

It was xxxx/page//index.js
parent 6f674b8c
......@@ -68,8 +68,7 @@ export class Head extends Component {
render () {
const { head, styles, __NEXT_DATA__ } = this.context._documentProps
const { pathname, buildId, assetPrefix, nextExport } = __NEXT_DATA__
const pagePathname = nextExport ? `${pathname}/index.js` : pathname
const pagePathname = getPagePathname(pathname, nextExport)
return <head>
<link rel='preload' href={`${assetPrefix}/_next/${buildId}/page${pagePathname}`} as='script' />
......@@ -136,8 +135,7 @@ export class NextScript extends Component {
render () {
const { staticMarkup, __NEXT_DATA__ } = this.context._documentProps
const { pathname, nextExport, buildId, assetPrefix } = __NEXT_DATA__
const pagePathname = nextExport ? `${pathname}/index.js` : pathname
const pagePathname = getPagePathname(pathname, nextExport)
return <div>
{staticMarkup ? null : <script dangerouslySetInnerHTML={{
......@@ -158,3 +156,9 @@ export class NextScript extends Component {
</div>
}
}
function getPagePathname (pathname, nextExport) {
if (!nextExport) return pathname
if (pathname === '/') return '/index.js'
return `${pathname}/index.js`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment