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

SSG sometimes doesn't format dates properly #77

Closed
tao opened this issue Oct 9, 2021 · 2 comments · Fixed by #109
Closed

SSG sometimes doesn't format dates properly #77

tao opened this issue Oct 9, 2021 · 2 comments · Fixed by #109

Comments

@tao
Copy link
Contributor

tao commented Oct 9, 2021

This might be a bit difficult to replicate... but I have a Github action that runs SSG daily to update the website. Sometimes it generates {{ date }} properly as September 24th, 2021 and sometimes it just prints the timestamp 2021-09-24 00:00:00.

For example:

Screenshot 2021-10-09 at 23 18 51

Screenshot 2021-10-09 at 23 18 43

I don't notice anything in the logs that's different, and the sync happens daily at the same time so nothing changes between them except new content being added.

If I do re-run the Github Action it generates the page with the normal formatted dates, so nothing changes between runs but it prints the date randomly.

@katwlodarczyk
Copy link

Have the same issue...

@jasonvarga
Copy link
Member

Just figured out the cause for this accidentally while working on another issue.

The date format is set in a middleware.
On regular content pages (entries etc) middleware doesn't actually get run.
On routes, (e.g. Route::statamic(), extra urls in the config, etc) middleware do get run.
So the date format will only be set on pages after any the middleware has run.
It seems random because we literally randomize the pages before generating them. (#57)

A short term "fix" would be to re-set the date format in the SSG somewhere, rather than rely on the middleware.
A better fix would be to run the middleware. As it stands, if you were attempting to run your own middleware, it wouldn't happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants