Time stamping entries #9
Comments
The If so, it's definitely something I can implement. How do you envision this working from a user perspective? As in, how would you tell Staticman that it needs to inject the current date in a field called Any thoughts will be appreciated. :) |
Yes, injecting a timestamp of some sort into each entry is what I'm after. If that can happen at the time of it's creation that would be great. As a workaround I was trying to find a way to assign a date to a hidden field <input type="hidden" name="field[date]" value="{{ site.time }}"> But obviously that went nowhere as I couldn't really find a way to grab the current time dynamically. So if there was a way to trigger Staticman to include a Noticed in your personal site repo that you were capturing the |
Ah, you're right! That was being used in the previous iteration of Staticman and hasn't been implemented in the rebuilt app. I'll add this tomorrow. Thanks. |
I've added support for this using the concept of generated fields. At the moment, the only type of generated field is date, but we could introduce other dynamic fields in the future (like geolocation, language, etc.) I need to add this to the docs, but in the meantime here's an example of how you can use it to add a generatedFields:
date:
type: date
options:
format: timestamp The current formats accepted are Let me know of any issues. |
This is fantastic. Seems to be working well for One thing I noticed... and I don't know if this is an issue or not. Using But if switched to
Any ideas there? I was able to filtered other Unix timestamps OK with Example: |
That's because I wonder if I should make seconds the default and create a |
Tested Maybe lean on the side of defaulting to seconds since that's how some of the Jekyll/Liquid filters are looking for it. Not sure what other static-site gens prefer. |
Added to docs: https://staticman.net/docs/configuration#generatedFields |
Allow to see the warning when the layout is unspecified
Is there a preferred way to capture the datetime of an entry? Noticed there's a
{@timestamp}
placeholder in the documentation but couldn't figure out how to use that for capturing comment data.I'm looking to get
.yml
datafiles something like this to iterate on and spit out in my Jekyll layouts:Thanks!
The text was updated successfully, but these errors were encountered: