Using Moment.js on datetime field for use in slug

Am I able to use moment.js to strip a year from a datetime field to use in a slug name?

collections:
  - label: "Games"
    name: "games"
    folder: "content/games"
    create: true
    identifier_field: gamenumber
    slug: 'game-{{gamenumber}}-{{opponent.teamname}}-{{gamedate|year}}' <-- something like that
    format: 'json'
    fields:
      - {label: "Game Number", name: "gamenumber", widget: "string"}
      - {label: "Game Date", name: "gamedate", widget: "datetime"}

Hi @p3lican, we have it for summary templates https://www.netlifycms.org/docs/beta-features/#summary-string-template-transformations.

I suggest opening a feature request to support it for slug.

1 Like

Thanks for the reply. I have an opened a feature request: https://github.com/netlify/netlify-cms/issues/4783

Haven’t done that before so if I need to update it any way I will do so. Just let me know. Thank you.

2 Likes