fix: add src prefix on index page (#45150)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
This commit is contained in:
Julius Marminge 2023-01-24 03:57:15 +01:00 committed by GitHub
parent 57d0e77f78
commit 98156d13ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 6 deletions

View file

@ -14,7 +14,7 @@ pnpm dev
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.jsx`. The page auto-updates as you edit the file.
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.

View file

@ -5,7 +5,7 @@ export default function RootLayout({ children }) {
<html lang="en">
{/*
<head /> will contain the components returned by the nearest parent
head.jsx. Find out more at https://beta.nextjs.org/docs/api-reference/file-conventions/head
head.js. Find out more at https://beta.nextjs.org/docs/api-reference/file-conventions/head
*/}
<head />
<body>{children}</body>

View file

@ -10,7 +10,7 @@ export default function Home() {
<div className={styles.description}>
<p>
Get started by editing&nbsp;
<code className={styles.code}>app/page.jsx</code>
<code className={styles.code}>app/page.js</code>
</p>
<div>
<a

View file

@ -174,6 +174,21 @@ export const installTemplate = async ({
})
})
)
// Change the `Get started by editing pages/index` / `app/page` to include `src`
const indexPageFile = path.join(
'src',
template === 'app' ? 'app' : 'pages',
`${template === 'app' ? 'page' : 'index'}.${mode === 'ts' ? 'tsx' : 'js'}`
)
await fs.promises.writeFile(
indexPageFile,
(
await fs.promises.readFile(indexPageFile, 'utf8')
).replace(
template === 'app' ? 'app/page' : 'pages/index',
template === 'app' ? 'src/app/page' : 'src/pages/index'
)
)
}
if (!eslint) {

View file

@ -68,9 +68,9 @@ export const projectSpecification: ProjectSpecification = {
deps: [],
devDeps: [],
files: [
'app/page.jsx',
'app/head.jsx',
'app/layout.jsx',
'app/page.js',
'app/head.js',
'app/layout.js',
'pages/api/hello.js',
'jsconfig.json',
],