I'm working on a redirect generator using 11ty and netlify-cms, and storing data in a shorturls.json
file.
My config.yml looks like this:
collections:
- name: "config"
label: "Admin"
description: "Administer site settings"
create: false
editor:
preview: false
files:
- label: short urls
name: shorturls
file: "_src/_data/shorturls.json"
widget: "object"
fields:
- label: "Short urls"
label_singular: "Short url"
name: "go"
widget: "list"
fields:
- { label: "From", name: "from", widget: "string", required: false }
- { label: "To", name: "to", widget: "string" }
- { label: "Redirect type", name: "status", widget: "hidden", default: "301" }
My json structure looks like this:
{
"go": [
{
"from": "/here",
"to": "/there"
},
{
"to": "/from-random"
}
]
}
Is there a way to populate a random value to the from
field? Is this going to need to be a custom widget?
The json output should then look something like this:
{
"go": [
{
"from": "/here",
"to": "/there"
},
{
"from": "/e6y0p13l",
"to": "/from-random"
}
]
}
Thanks