GSA / digitalgov.gov

Digital.gov: Better websites. Better government.
https://digital.gov
Other
221 stars 299 forks source link

[Netlify CMS] Cannot use future date in path/slug #3169

Closed hursey013 closed 3 years ago

hursey013 commented 4 years ago

References:

The out of the box behavior with Netlify CMS is to use today's date within the path/slug - there is currently no way to define a custom datetime widget to be used in the slug. Our current workaround is to use several string input fields (month, date, year) which can be used in the slug, and then using a preSave hook to convert those values into a date frontmatter value.

Ideally, in the future we can drop the string fields and define a future date with a datetime widget and reference the month, date, year as described in this issue by @jeremyzilar: https://github.com/netlify/netlify-cms/issues/3750

jeremyzilar commented 4 years ago

@hursey013 Yes, I was trying to use the date in the filename and was not able to (see how I did it here).

Then I remembered that the date in the filename was not performing a function in the event page. The date was in the filename to ensure that the filename was unique in the repo. So, as far as filenames go, they don't have to include the date, as that is set in the front-matter of the event page.

Separately, you might want to explore if there are issues with having two identical filenames, as you most certainly will have events that have the same title over time, e.g. USWDS Monthly Call

jeremyzilar commented 4 years ago

To test to see if you can drop the date from the filename, I would test

  1. will these event pages load
  2. Is HUGO able to perform the right lookup to find the right pages for these when you link to both of these pages from a blog post
events/
  - 02/
    - uswds-monthly-call.md
  - 03/
    - uswds-monthly-call.md

I would also try adding an event with the same name, within the same month via NetlifyCMS, and see if it will create a unique filename for the new event, like this:

events/
  - 02/
    - uswds-monthly-call.md
    - uswds-monthly-call-01.md
hursey013 commented 4 years ago

@jeremyzilar thanks for the suggestions ❤️ I think right now the main discussion is whether the team is ok having the structure of the markdown files potentially not match the public facing urls/dates associated with posts/events. I think if we move to be 100% in on Netlify CMS how markdown files are organized isn't a big deal, it's more if we have folks that are going to continue to find/edit things directly in GitHub.

jeremyzilar commented 4 years ago

@hursey013 So I was totally worried about that too 😬. I mean, that is how I had known and edited the files for like 4 years. But once I made the switch over to the Netlify CMS for the Brooklyn Rail (just the /events/) and used it for about a week, I sorta never went back to editing pages in a code editor. The primary way I made page edits now is through the CMS editor, which I never thought would happen.

github-actions[bot] commented 3 years ago

Hello! 👋 It looks like this issue is stale because it has been open 60 days with no activity. This is usually because the request was already solved or it is no longer applicable. If this issue should remain open, remove the stale label or add a comment. Otherwise, this will be closed in 7 days.

reteps commented 1 year ago

Please reopen