Skip to content

Commit

Permalink
Add docs for custom templates option (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
beerose authored Dec 17, 2021
1 parent 922f3f5 commit 57fcb45
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
44 changes: 44 additions & 0 deletions app/pages/docs/blitz-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,50 @@ module.exports = {
}
```
## Codegen {#codegen}
If you want to use custom templates with `blitz generate` instead of the
default ones (e.g. with different styles), you can provide a path to the
local template directory:
```js
module.exports = {
codegen: {
templateDir: "./templates",
},
}
```
The template directory should have the following structure:
```
.
├── form
│ └── __ModelName__Form.tsx
├── mutation
│ └── __input__.ts
├── mutations
│ ├── create__ModelName__.ts
│ ├── delete__ModelName__.ts
│ └── update__ModelName__.ts
├── page
│ ├── __modelIdParam__
│ │ └── edit.tsx
│ ├── __modelIdParam__.tsx
│ ├── index.tsx
│ └── new.tsx
├── queries
│ ├── get__ModelName__.ts
│ └── get__ModelNames__.ts
└── query
└── __name__.ts
```
If some folders are omitted in your custom template directory,
`blitz generate` will fallback to the default templates. You can check
them out
[here](https://github.com/blitz-js/blitz/tree/canary/packages/generator/templates).
## CLI {#cli}
### Clear Console On Blitz Dev {#clear-console-on-blitz-dev}
Expand Down
7 changes: 7 additions & 0 deletions app/pages/docs/cli-generate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,10 @@ field to the `Task` model.
```bash
blitz generate model task subheading:string
```

### Custom templates {#custom-templates}

If you want to use custom templates with `blitz generate` instead of the
default ones (e.g. with different styles), you can provide a path to the
local directory with template files. You can specify it in your
`blitz.config.ts` file. [Read more here](/docs/blitz-config#codegen).

0 comments on commit 57fcb45

Please sign in to comment.