Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
147a5ce6
Commit
147a5ce6
authored
May 09, 2017
by
Arunoda Susiripala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix server rendering issue for normal apps.
parent
42f1d2ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
link.js
lib/link.js
+1
-0
render.js
server/render.js
+7
-7
No files found.
lib/link.js
View file @
147a5ce6
...
@@ -133,6 +133,7 @@ export default class Link extends Component {
...
@@ -133,6 +133,7 @@ export default class Link extends Component {
// "<page>/index.html" directly.
// "<page>/index.html" directly.
const
endsWithSlash
=
/
\/
$/
.
test
(
props
.
href
)
const
endsWithSlash
=
/
\/
$/
.
test
(
props
.
href
)
if
(
if
(
typeof
__NEXT_DATA__
!==
'undefined'
&&
__NEXT_DATA__
.
nextExport
&&
__NEXT_DATA__
.
nextExport
&&
!
endsWithSlash
!
endsWithSlash
)
{
)
{
...
...
server/render.js
View file @
147a5ce6
...
@@ -49,6 +49,13 @@ async function doRender (req, res, pathname, query, {
...
@@ -49,6 +49,13 @@ async function doRender (req, res, pathname, query, {
const
dist
=
getConfig
(
dir
).
distDir
const
dist
=
getConfig
(
dir
).
distDir
// realPathname is pretty useful in the document.js
// In there, we include a proper valid resolved path.
// That helps us to server that JSON page directly from a static server.
// Basically, this is a requirment for next-export
const
pageRealPath
=
await
resolvePath
(
join
(
dir
,
dist
,
'dist'
,
'pages'
,
page
))
const
realPathname
=
pageRealPath
.
replace
(
join
(
dir
,
dist
,
'dist'
,
'pages'
),
''
)
let
[
Component
,
Document
]
=
await
Promise
.
all
([
let
[
Component
,
Document
]
=
await
Promise
.
all
([
requireModule
(
join
(
dir
,
dist
,
'dist'
,
'pages'
,
page
)),
requireModule
(
join
(
dir
,
dist
,
'dist'
,
'pages'
,
page
)),
requireModule
(
join
(
dir
,
dist
,
'dist'
,
'pages'
,
'_document'
))
requireModule
(
join
(
dir
,
dist
,
'dist'
,
'pages'
,
'_document'
))
...
@@ -91,13 +98,6 @@ async function doRender (req, res, pathname, query, {
...
@@ -91,13 +98,6 @@ async function doRender (req, res, pathname, query, {
if
(
res
.
finished
)
return
if
(
res
.
finished
)
return
// realPathname is pretty useful in the document.js
// In there, we include a proper valid resolved path.
// That helps us to server that JSON page directly from a static server.
// Basically, this is a requirment for next-export
const
pageRealPath
=
await
resolvePath
(
join
(
dir
,
'pages'
,
pathname
))
const
realPathname
=
pageRealPath
.
replace
(
join
(
dir
,
'pages'
),
''
)
const
doc
=
createElement
(
Document
,
{
const
doc
=
createElement
(
Document
,
{
__NEXT_DATA__
:
{
__NEXT_DATA__
:
{
props
,
props
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment