1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Fix '/' page serving issue.

It was xxxx/page//index.js
This commit is contained in:
Arunoda Susiripala 2017-05-11 06:20:58 -07:00
parent 6f674b8c0a
commit 2796c08ef7

View file

@ -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`
}