@@ -57,7 +57,7 @@ function resolveRoutePath(basePath: string, relFilePath: string) {
5757 . replace ( / ^ ( \/ i n d e x ) { 2 } $ / , '' ) // remove '/index/index'
5858 . replace ( / \/ i n d e x $ / , '' ) // remove '/index'
5959 . replace ( / \/ R E A D M E $ / i, '' ) // remove '/README'
60- . replace ( / \/ _ l a y o u t $ / , '' ) // remove '/_layout'
60+ . replace ( / \/ _ ? l a y o u t $ / , '' ) // remove '/_layout' and '/layout '
6161 . replace ( / \/ 4 0 4 $ / , '/*' ) // transform '/404' to '/*' so this route acts like a catch-all for URLs that we don't have explicit routes for
6262 . replace ( / \/ \[ \. { 3 } .* ?\] $ / , '/*' ) // transform '/post/[...all]' to '/post/*'
6363 . replace ( / \/ \[ ( .* ?) \] / g, '/:$1' ) ; // transform 'user/[id]' to 'user/:id'
@@ -68,7 +68,8 @@ function resolveRoutePath(basePath: string, relFilePath: string) {
6868}
6969
7070function isLayoutFile ( filePath : string ) {
71- return path . basename ( filePath , path . extname ( filePath ) ) === '_layout' ;
71+ const name = path . basename ( filePath , path . extname ( filePath ) ) ;
72+ return name === '_layout' || name === 'layout' ;
7273}
7374
7475function is404File ( filePath : string ) {
@@ -92,7 +93,10 @@ export class PagesService extends EventEmitter {
9293 return ( this . _startPromise = Promise . all (
9394 this . config . pages . config . map (
9495 async ( { basePath, dir, pattern, ignore } ) => {
95- pattern = [ '**/_layout.{js,jsx,ts,tsx,md,mdx}' , ...toArray ( pattern ) ] ;
96+ pattern = [
97+ '**/{_layout,layout}.{js,jsx,ts,tsx,md,mdx}' ,
98+ ...toArray ( pattern ) ,
99+ ] ;
96100 ignore = toArray ( ignore ) ;
97101
98102 const relFilePaths = fg . sync ( pattern , { cwd : dir , ignore } ) ;
0 commit comments