Skip to content

Commit 08c5375

Browse files
committed
Merge branch 'master' of github.com:Codpoe/vite-plugins-for-react
2 parents 7fd50fa + 58707dc commit 08c5375

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/routes/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-conventional-routes",
3-
"version": "0.1.12-beta.9",
3+
"version": "0.1.12-beta.10",
44
"description": "vite plugin to generate conventional routes",
55
"keywords": [
66
"vite",

packages/routes/src/PagesService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function resolveRoutePath(basePath: string, relFilePath: string) {
5757
.replace(/^(\/index){2}$/, '') // remove '/index/index'
5858
.replace(/\/index$/, '') // remove '/index'
5959
.replace(/\/README$/i, '') // remove '/README'
60-
.replace(/\/_layout$/, '') // remove '/_layout'
60+
.replace(/\/_?layout$/, '') // remove '/_layout' and '/layout'
6161
.replace(/\/404$/, '/*') // 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

7070
function 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

7475
function 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

Comments
 (0)