fix: add src prefix on index page (#45150)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
This commit is contained in:
parent
57d0e77f78
commit
98156d13ce
6 changed files with 21 additions and 6 deletions
|
@ -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`.
|
||||
|
||||
|
|
|
@ -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>
|
|
@ -10,7 +10,7 @@ export default function Home() {
|
|||
<div className={styles.description}>
|
||||
<p>
|
||||
Get started by editing
|
||||
<code className={styles.code}>app/page.jsx</code>
|
||||
<code className={styles.code}>app/page.js</code>
|
||||
</p>
|
||||
<div>
|
||||
<a
|
|
@ -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) {
|
||||
|
|
|
@ -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',
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue