Skip to content

Commit

Permalink
Fix: Fixed NextJsPage bug
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Apr 17, 2024
1 parent 354ee63 commit 7bd4849
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ mac@Macs-MBP~/D/react-app$ methane g -np pageName -ct server
As you already know, in **NextJS** dynamic pages are pages whose content is determined by parameters included in the URL. For example _/product/1_ is a dynamic URL. Now Methane can also help you create dynamic pages. Usually, a dynamic page would be nested within a page. For example, I've a products page already _/products_, my dynamic page would most likely be productId. So using Methane, you can generate a dynamic page using the command below

```bash
mac@Macs-MBP~/D/react-app$ methane g -ndp productId -sp /products
mac@Macs-MBP~/D/react-app$ methane g -nid productId -sp /products

```

##### Command Arguments

1. **-npd** -npid (Next Dynamic Page) is the dynamic page name, which in this case is _productId_
1. **-nid** -nid (Next Dynamic Page Id) is the dynamic page name, which in this case is _productId_
2. **-sp** -sp is an optional parameter called (Start Page) which is indicates the folder to place the dynamic page in. You don't need to specify the default nextJS _/app_ when specifying the folder to place the dynamic page.

**Optionally, you can specify your nextJs page to be a server or client page** To do this, Simply add the **ct** flag, then you can specify server or client omitting the **ct** would generate a client page by default.
Expand Down
2 changes: 1 addition & 1 deletion helpers/generators/generateNextJsDynamicPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const generatePage = async (

generateDynamicPageFile(
dynamicId,
generatePageFolder ? "index" : name,
captitalizeWord(dynamicId),
pageDirName,
pageResolver,
componentType
Expand Down
6 changes: 3 additions & 3 deletions helpers/generators/generateNextJsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export const generatePage = async (
const generatePageFolder =
readUserConfig.readConfig().generateFolder === "true";

const legitPageName: string = generatePageFolder ? "index" : name;
//const legitPageName: string = generatePageFolder ? "index" : name;

let pageDirName = generatePageFolder
? path.join(pagesDir, legitPageName)
? path.join(pagesDir, name)
: path.join(pagesDir);

/**
Expand All @@ -123,7 +123,7 @@ export const generatePage = async (
*/
if (startPage) {
pageDirName = generatePageFolder
? path.join(pagesDir + startPage, legitPageName)
? path.join(pagesDir + startPage, name)
: path.join(pagesDir + startPage);
}

Expand Down

0 comments on commit 7bd4849

Please sign in to comment.