diff --git a/app/pages/docs/blitz-config.mdx b/app/pages/docs/blitz-config.mdx index 1220cff9..3462ff34 100644 --- a/app/pages/docs/blitz-config.mdx +++ b/app/pages/docs/blitz-config.mdx @@ -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} diff --git a/app/pages/docs/cli-generate.mdx b/app/pages/docs/cli-generate.mdx index 6f1d2573..1632d1bd 100644 --- a/app/pages/docs/cli-generate.mdx +++ b/app/pages/docs/cli-generate.mdx @@ -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).