mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(docs): describe addTypeTemplate
This commit is contained in:
parent
ff48d797c6
commit
b4030afa75
@ -1816,7 +1816,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
|
||||
### `addTemplate`
|
||||
|
||||
Renders given template using lodash template during build into the project buildDir.
|
||||
Renders given template using [lodash template](https://lodash.com/docs/4.17.15#template) during build into the project buildDir.
|
||||
|
||||
#### Type
|
||||
|
||||
@ -1881,6 +1881,63 @@ A template object or a string with the path to the template. If a string is prov
|
||||
|
||||
### `addTypeTemplate(templateOptions)`
|
||||
|
||||
Renders given template using [lodash template](https://lodash.com/docs/4.17.15#template) during build into the project buildDir, then registers it as types.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
function addTypeTemplate (template: NuxtTypeTemplate | string): NuxtTemplate
|
||||
|
||||
interface NuxtTemplate {
|
||||
src?: string
|
||||
filename?: string
|
||||
dst?: string
|
||||
options?: Record<string, any>
|
||||
getContents?: (data: Record<string, any>) => string | Promise<string>
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `template`
|
||||
|
||||
**Type**: `NuxtTypeTemplate | string`
|
||||
|
||||
**Required**: `true`
|
||||
|
||||
A template object or a string with the path to the template. If a string is provided, it will be converted to a template object with `src` set to the string value. If a template object is provided, it must have the following properties:
|
||||
|
||||
- `src` (optional)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
Path to the template. If `src` is not provided, `getContents` must be provided instead.
|
||||
|
||||
- `filename` (optional)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
Filename of the template. If `filename` is not provided, it will be generated from the `src` path. In this case, the `src` option is required.
|
||||
|
||||
- `dst` (optional)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
Path to the destination file. If `dst` is not provided, it will be generated from the `filename` path and nuxt `buildDir` option.
|
||||
|
||||
- `options` (optional)
|
||||
|
||||
**Type**: `Options`
|
||||
|
||||
Options to pass to the template.
|
||||
|
||||
- `getContents` (optional)
|
||||
|
||||
**Type**: `(data: Options) => string | Promise<string>`
|
||||
|
||||
A function that will be called with the `options` object. It should return a string or a promise that resolves to a string. If `src` is provided, this function will be ignored.
|
||||
|
||||
### `updateTemplates({ filter?: ResolvedNuxtTemplate => boolean })`
|
||||
|
||||
## Nitro
|
||||
|
Loading…
Reference in New Issue
Block a user