Staticman: How to generate slug from field data?

Created on 10 Mar 2019  路  2Comments  路  Source: eduardoboucas/staticman

Hi, sorry if this has been covered before but I couldn't find it anywhere in the docs or issues.

I want to add a generated field to create a slug from fields[name] that I can use as the file name. I see there is a slugify type but no idea what syntax I need to use and whether I can specifiy a field to use?

Here's my config, any help would be appreciated 馃憤

companies:
  allowedFields: ["name", "description", "location"]
  branch: "master"
  commitMessage: "Add company - {fields.slug}"
  filename: "{fields.name}"
  format: "json"
  generatedFields:
    slug:
      type: slugify
      ????                       <-- What goes here?
    dateCreated:
      type: date
      options:
        format: "timestamp-seconds"
  moderation: true
  name: "Dev Wales"
  path: "_data/companies"
  requiredFields: ["name"]
question

Most helpful comment

I had been looking all over and found the answer here: https://github.com/eduardoboucas/hugo-plus-staticman/blob/master/staticman.yml

generatedFields:
    date:
      type: date
    slug:
      type: slugify
      options:
        field: title

filename: "{fields.slug}"

All 2 comments

@eduardoboucas could you please help us out?

I had been looking all over and found the answer here: https://github.com/eduardoboucas/hugo-plus-staticman/blob/master/staticman.yml

generatedFields:
    date:
      type: date
    slug:
      type: slugify
      options:
        field: title

filename: "{fields.slug}"
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ex-punctis picture ex-punctis  路  8Comments

BloggerBust picture BloggerBust  路  6Comments

jkbecker picture jkbecker  路  5Comments

zburgermeiszter picture zburgermeiszter  路  8Comments

eduardoboucas picture eduardoboucas  路  11Comments