decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Filter date for a field entry to use in the slug

Open p3lican opened this issue 4 years ago • 2 comments

I'd like to inject a "Game or Event Year" into the slug. Rather than creating fields for day and year, I'd like to be able to strip the year from the single "Event Date" field entry and use that in my slug.

Basically exactly what you have done for summaries: https://www.netlifycms.org/docs/beta-features/#summary-string-template-transformations.

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

p3lican avatar Dec 30 '20 16:12 p3lican

To add some more context, one can inject the file creation date using {{year}}: https://www.netlifycms.org/docs/configuration-options/#slug

but this issue is about using a specific field's date and formatting it.

erezrokah avatar Jan 04 '21 10:01 erezrokah

Any idea if this is going to be done (or if it's hard to do)? It looks like a no-brainer since there is already https://www.netlifycms.org/docs/beta-features/#summary-string-template-transformations .

p4r4noj4 avatar Jun 13 '22 18:06 p4r4noj4