decaporg / decaporg/decap-cms

Use content `date` field instead of built-in template tags

Open
#6,801 1 comment 2 reactions 0 assignees View on GitHub
area: configuration type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Is your feature request related to a problem? Please describe.**

Hello, I have content that is future-dated for upcoming events. Our current config uses the built template date tags `path: "{{year}}/{{month}}/{{slug}}"` as part of the path for where the file should be saved.

It would be great to use something like `{{fields.date.year}}` to get the date components from the collection field instead of the built-in date template tags. This would allow us to the path to match to the `date` in the front matter.

Is is possible to get the year, month, day from by doing `{{fields.date.year}}, {{fields.date.month}}, {{fields.date.day}}`.

Top level **path** setting for file location:
```
path: "{{year}}/{{month}}/{{slug}}" // would be great to reference {{fields.date.year}}, etc...
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
```

Collection field to reference in `path` for content type:
```
- label: "Start Date/Time"
name: "date"
widget: "datetime"
dateFormat: "YYYY-MM-DD" # e.g. 2021-11.23
timeFormat: "HH:mm" # e.g. 21:00
format: "YYYY-MM-DD HH:mm:00 -0500"
hint: "The start date and time of the event (Note: uses a 24hr clock, e.g. 13:00)"
```

**Describe the solution you'd like**

Is is possible to get the year, month, day from by doing `{{fields.date.year}}, {{fields.date.month}}, {{fields.date.day}}`?

**Describe alternatives you've considered**
N/A

**Additional context**
N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.