Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter date for a field entry to use in the slug #4783

Open
p3lican opened this issue Dec 30, 2020 · 3 comments · May be fixed by #6690
Open

Filter date for a field entry to use in the slug #4783

p3lican opened this issue Dec 30, 2020 · 3 comments · May be fixed by #6690
Labels
area: slugs type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@p3lican
Copy link

p3lican commented Dec 30, 2020

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 p3lican added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Dec 30, 2020
@p3lican p3lican changed the title Please replace with a clear and descriptive title Filter date for a field entry to use in the slug Dec 30, 2020
@erezrokah
Copy link
Contributor

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.

@p4r4noj4
Copy link

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 .

stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Feb 10, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
@stormwarning stormwarning linked a pull request Feb 10, 2023 that will close this issue
4 tasks
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Mar 8, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Mar 14, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Apr 5, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue May 20, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Jun 15, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
stormwarning added a commit to stormwarning/netlify-cms that referenced this issue Aug 7, 2023
Process template filters first, then strip `'` and `.` characters from
slug strings.

Fixes decaporg#4783
@germs-at
Copy link

Yes, I want to do something like this too!

slug: 'game-{{gamenumber}}-{{opponent.teamname}}-{{gamedate | date('YYYY')}}'
slug: "{{date | date('YYYY-MM-DD')}}_{{slug}}"

Does that work yet?

I am inclined to solve this on the path level with:
path: "{{date | date('YYYY-MM-DD')}}_{{slug}}/index"

Hope that works at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: slugs type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants