You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Turn your Netlify CMS collections into TypeScript typings!**
8
+
**Turn your Netlify CMS collections into TypeScript types!**
9
9
10
10
<br />
11
11
@@ -23,80 +23,74 @@ This package generates a [TypeScript](https://www.typescriptlang.org/) schema of
23
23
24
24
# Installation
25
25
26
-
The package can be installed globally or as a `devDependency` using NPM or Yarn.
27
-
28
-
**NPM:**
29
-
30
26
```bash
31
-
npm install -g netlify-ts
32
-
33
-
# or
34
-
35
27
npm install -D netlify-ts
36
28
```
37
29
38
-
**Yarn:**
39
-
40
-
```bash
41
-
yarn global add netlify-ts
42
-
43
-
# or
44
-
45
-
yarn add -D netlify-ts
46
-
```
47
-
48
30
# Usage
49
31
50
-
## Method 1: CLI
32
+
## CLI
51
33
52
-
The main method of usage is through the command-line. Having installed the package either globally or in project's `devDependencies`, simply call `netlify-ts` with a parameter pointing to your Netlify CMS admin `config.yml` file.
34
+
The main method of usage is through the command-line. Having installed the package either globally or in project's `devDependencies`, simply call `netlify-ts` with a parameter pointing to your Netlify CMS `config.yml` file.
53
35
54
36
```bash
55
-
netlify-ts public/admin/config.yml
37
+
npx netlify-ts path/to/config.yml
56
38
```
57
39
58
-
This generates by default a `netlify-types.ts` file in the project root containing types for your netlify content types.
40
+
This generates a `netlify-types.ts` file in the project root containing types for your Netlify CMS collections.
59
41
60
42
### Custom output location
61
43
62
44
You can also specify a custom output location by providing a second optional parameter. Omitting the filename outputs a file in the given directory with the default filename (`netlify-types.ts`).
In case the CLI doesn't suit your project workflow or you need to invoke the type generation inside your code, the project exposes both a `createNetlifyTypes` and `createNetlifyTypesAsync`function that returns the generated type file as a string.
52
+
In case the CLI doesn't suit your workflow or you need to invoke the type generation inside your code, the project exposes a function that returns the generated types as a string.
0 commit comments