diff --git a/.changeset/rude-trainers-visit.md b/.changeset/rude-trainers-visit.md new file mode 100644 index 0000000000..b748dadd09 --- /dev/null +++ b/.changeset/rude-trainers-visit.md @@ -0,0 +1,5 @@ +--- +"blitz": patch +--- + +Fix blitz install for recipes that use the path helper to check if ./src/pages directory is available, otherwise use ./pages diff --git a/packages/blitz/src/installer/utils/paths.ts b/packages/blitz/src/installer/utils/paths.ts index e8125d80f2..16b9b51e8d 100644 --- a/packages/blitz/src/installer/utils/paths.ts +++ b/packages/blitz/src/installer/utils/paths.ts @@ -18,12 +18,23 @@ function getBlitzPath(type: string) { } } +function findPageDir() { + const srcPagePath = `src/pages` + const srcPage = fs.existsSync(path.resolve(srcPagePath)) + + if (srcPage) { + return srcPagePath + } else { + return `pages` + } +} + export const paths = { document() { - return `pages/_document${ext(true)}` + return `${findPageDir()}/_document${ext(true)}` }, app() { - return `pages/_app${ext(true)}` + return `${findPageDir()}/_app${ext(true)}` }, blitzServer() { return getBlitzPath("server") @@ -32,7 +43,7 @@ export const paths = { return getBlitzPath("client") }, entry() { - return `pages/index${ext(true)}` + return `${findPageDir()}/index${ext(true)}` }, nextConfig() { return `next.config.js`