-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Make GroupByParamDate work with string params #3983
Comments
This is because the function does not convert the a timestamp string into a In my testing when I date: time.Time{wall:0x0, ext:63642202692, loc:(*time.Location)(nil)} I found |
I'm seeing the same problem with 0.32.4. Is there a workaround for this (other than not using GroupByParamDate)? |
@timn For my project I remapped the field in the CMS to the Not an awesome solution and no other workaround that I am aware of. I'd love to fix this. I was able to locate the problem but I don't know enough Go to get started. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This is still a bug. It's also not possible to sort a collection of a page resources and normal pages by a custom date field for the same reasons. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This is still a bug :) |
First, I'm unable to reproduce the Second, Hugo treats a few(?) reserved page parameter and forces them to a JSON does not support timestamps. They're all treated as strings. Don't use JSON. YAML does support timestamps, but the go-yaml package does not and will not until they decide to create a v3 of the package. I was able to comment out that TOML does support timestamps, and the BurntSushi toml package parses them correctly. 🎉 So, as of today, you need to use TOML front matter. I'll leave this issue open and mark it as Upstream since go-yaml should support this but doesn't. PS - If you want to see the type of a variable from a template, use |
@moorereason This is good info, but what if we could just cast a value to a time format in Hugo? Hypothetically |
|
As of |
Kia ora everyone! I have had this issue for a while and thought that I'd create a project that replicates it with the latest
As far as I can tell, this syntax respects the documentation: https://gohugo.io/templates/lists/#by-page-parameter-in-date-format. I hope this helps someone track this down! |
Your front matter format is TOML, and you have quote-encapsulated the A) I suspect that the documentation was written against a working example with TOML front matter where the timestamp was not quote-encapsulated. Comments...
EDIT: I thought I had option "A" working, but now it is not. |
Ah, amazing. Thank you for catching that - I clearly hadn't read the TOML spec but I have had a look through it now. I shall convert all my stuff to TOML and ensure I am not quoting date/time values in the future! |
This is labeled "Upstream" which is partially correct. But |
My 50 cents without having read all the discussion above:
But I do understand that there will be other dates (eventDate ...) ... That said, I would expect this to kind of work for both YAML and TOML, but if it doesn't we should consider trying to convert the string to date on the fly inside |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm trying to group some of my articles by date using the
project_date
param defined in the front matter, but can't make it work. I end up with aruntime error: index out of range
error in the console.According to the documentation, it should look like this:
{{ range .Data.Pages.GroupByParamDate "project_date" "2006" "desc"}}
Any thoughts?
Update: I was using version 0.26 and upgraded to 0.30.2 and still experiencing the issue.
The text was updated successfully, but these errors were encountered: