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
a67b6ee1
Commit
a67b6ee1
authored
Apr 06, 2019
by
Joe Haddad
Committed by
Tim Neutkens
Apr 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix page resolution (#6920)
Previously this didn't work properly with nested pages.
parent
d4048790
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
index.ts
packages/next/build/index.ts
+8
-5
select-pages.test.js.snap
...unit/select-pages/__snapshots__/select-pages.test.js.snap
+3
-3
index.mdx
test/unit/select-pages/pages/c/index.mdx
+0
-0
No files found.
packages/next/build/index.ts
View file @
a67b6ee1
...
@@ -46,9 +46,12 @@ function flatten<T>(arr: T[][]): T[] {
...
@@ -46,9 +46,12 @@ function flatten<T>(arr: T[][]): T[] {
}
}
function
getPossibleFiles
(
pageExtensions
:
string
[],
pages
:
string
[])
{
function
getPossibleFiles
(
pageExtensions
:
string
[],
pages
:
string
[])
{
const
res
=
pages
.
map
(
page
=>
const
res
=
pages
.
map
(
page
=>
{
[
page
].
concat
(
pageExtensions
.
map
(
e
=>
`
${
page
}
.
${
e
}
`
))
const
pi
=
path
.
join
(
page
,
'index'
)
)
return
[
page
,
pi
]
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
page
}
.
${
e
}
`
))
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
pi
}
.
${
e
}
`
))
})
return
flatten
<
string
>
(
res
)
return
flatten
<
string
>
(
res
)
}
}
...
@@ -81,12 +84,12 @@ export async function getSpecifiedPages(
...
@@ -81,12 +84,12 @@ export async function getSpecifiedPages(
resolvedPage
=
getPossibleFiles
(
pageExtensions
,
[
resolvedPage
=
getPossibleFiles
(
pageExtensions
,
[
path
.
join
(
pagesDir
,
p
),
path
.
join
(
pagesDir
,
p
),
p
,
p
,
]).
find
(
f
=>
fs
.
existsSync
(
f
))
]).
find
(
f
=>
fs
.
existsSync
(
f
)
&&
fs
.
lstatSync
(
f
).
isFile
()
)
}
else
{
}
else
{
resolvedPage
=
getPossibleFiles
(
pageExtensions
,
[
resolvedPage
=
getPossibleFiles
(
pageExtensions
,
[
path
.
join
(
pagesDir
,
p
),
path
.
join
(
pagesDir
,
p
),
path
.
join
(
dir
,
p
),
path
.
join
(
dir
,
p
),
]).
find
(
f
=>
fs
.
existsSync
(
f
))
]).
find
(
f
=>
fs
.
existsSync
(
f
)
&&
fs
.
lstatSync
(
f
).
isFile
()
)
}
}
return
{
original
:
p
,
resolved
:
resolvedPage
||
null
,
removePage
}
return
{
original
:
p
,
resolved
:
resolvedPage
||
null
,
removePage
}
})
})
...
...
test/unit/select-pages/__snapshots__/select-pages.test.js.snap
View file @
a67b6ee1
...
@@ -12,7 +12,7 @@ Array [
...
@@ -12,7 +12,7 @@ Array [
"/_app.js",
"/_app.js",
"/_document.js",
"/_document.js",
"/b.jsx",
"/b.jsx",
"/c.mdx",
"/c
/index
.mdx",
]
]
`;
`;
...
@@ -56,7 +56,7 @@ Array [
...
@@ -56,7 +56,7 @@ Array [
"/_document.js",
"/_document.js",
"/a.js",
"/a.js",
"/b.jsx",
"/b.jsx",
"/c.mdx",
"/c
/index
.mdx",
]
]
`;
`;
...
@@ -74,6 +74,6 @@ Array [
...
@@ -74,6 +74,6 @@ Array [
"/_document.js",
"/_document.js",
"/a.js",
"/a.js",
"/b.jsx",
"/b.jsx",
"/c.mdx",
"/c
/index
.mdx",
]
]
`;
`;
test/unit/select-pages/pages/c.mdx
→
test/unit/select-pages/pages/c
/index
.mdx
View file @
a67b6ee1
File moved
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