Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oscarotero/netlify_cms_config
Netlify CMS config generator
https://github.com/oscarotero/netlify_cms_config
deno generator netlify-cms
Last synced: 9 days ago
JSON representation
Netlify CMS config generator
- Host: GitHub
- URL: https://github.com/oscarotero/netlify_cms_config
- Owner: oscarotero
- Created: 2022-05-27T14:30:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-10T22:02:27.000Z (over 1 year ago)
- Last Synced: 2024-10-16T19:15:55.257Z (about 1 month ago)
- Topics: deno, generator, netlify-cms
- Language: TypeScript
- Homepage: https://deno.land/x/netlify_cms_config
- Size: 43 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Netlify CMS Config generator
This is a Deno's TypeScript library to generate the `config.yml` file to
configure the Netlify CMS easily. For more info about the Netlify Configuration
Options,
[go to the original documentation website](https://www.netlifycms.org/docs/configuration-options/).## Usage example
The library is built in TypeScript, including the options descriptions as
comments, so you can take advantage of your VSCode (or any other IDE) like
autocomplete, descriptions etc.### Create simple field
```ts
import f from "./mod.ts";const field = f.string("Your name");
console.log(field.toJSON());
```This code generates the following result:
```js
{
label: "Your name",
name: "your_name",
widget: "string"
}
```By default, the `name` value is generated automatically from the `label`. But
you can change it or add more options:```ts
const field = f.string("Your name")
.name("name")
.required(false)
.default("Default name")
.toJSON();
```This outputs:
```js
{
label: "Your name",
name: "name",
widget: "string",
required: false,
"default": "Default name",
}
```## Create a folder collection
```ts
import f from "./mod.ts";const posts = f.folder("Posts", "/posts")
.create(true)
.slug("{{slug}}")
.delete(true)
.fields([
f.string("Title"),
f.datetime("Published at"),
f.markdown("Body"),
])
.toJSON();
```This outputs:
```js
{
label: "Posts",
name: "posts",
folder: "/posts",
create: true,
slug: "{{slug}}",
delete: true,
fields: [
{
label: "Title",
name: "title",
widget: "string"
},
{
label: "Published at",
name: "published_at",
widget: "datetime"
},
{
label: "Body",
name: "body",
widget: "markdown"
},
]
}
```## Create a files collection
```ts
import f from "./mod.ts";const posts = f.files("Pages")
.file("Page 1", "page-1.md", [
f.string("Title"),
f.datetime("Published at"),
f.markdown("Body"),
])
.file("Page 2", "page-2.md", [
f.string("Title"),
f.datetime("Published at"),
f.markdown("Body"),
])
.toJSON();
```## Default values
To avoid repetition, you can set default values:
```ts
import f from "./mod.ts";// Special case to set the `required` option to false
// applied to all fields
f.defaultRequired = false;// Configure settings individually by field
f.defaults.markdown.buttons(["bold", "italic", "link"]);
f.defaults.list.collapsed(true).minimizeCollapsed(true);
```