-
Notifications
You must be signed in to change notification settings - Fork 97
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
Automatic date (published) and modified date (updated) #197
Comments
Hi, I would really like such a feature. I would guess two possible source to get the date off:
see my posts_in_subfolders test: https://github.com/cobalt-org/cobalt.rs/tree/master/tests/fixtures/posts_in_subfolder/posts Maybe getting it from a filename like YYYYMMDD post.md would be a third possible solution. Greetings Uwe |
Thanks, I'll try to get a dirty implementation of this this weekend. There's filetime that would allow us to get it from the file properties in a cross platform way. Problem with that is passing a bunch of file data around instead of just reading the contents. |
For Jekyll compatibility, we'd want to support YYYY-MM-DD-name.extension More specifically, their filename regexes are DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{4}-\d{2}-\d{2})-(.*)(\.[^.]+)$! |
Would something like filetime work? I didn't think git preserved mtime so it'd work on your local machine but if you rely on something like travis to generate your site, then the dates will all be off. |
I didn't know that regarding git. However, at least having automatic creation time with filetime would be cool. Plus, Creation time is already one of the properties so it would be easier to add anyway. |
I've not seen any pages confirming, but I doubt git also preserves ctime and atime as well. To be more automatic than extracting from the file name, I think you'll need to dig into the git history with all that entails (gracefully handling non-git code with some config flags to control behavior at minimum; SCM abstraction ideally). |
True. Starting a |
Is there a reason we couldn't use |
On the other hand, we could look in git for more information. The question is how we should interpret it. published
modified
|
This is inspired by cobalt-org#197 and Jekyll. Jekyll gets the filename from a file. The main difference between Jekyll and this change is that we aren't supporting 2-digit years. In cobalt-org#197, the idea was brought up of extracting the date from the directory structure. I like this approach. I could imagine having at least year directories (don't blog enough to make day directories worth while). The challenge comes in how to detect this.
#324 adds inferring the |
Hugo has an optionally-enabled feature for exposing git information. One aspect of it is it sets a modification time on a file based on the last commit to the file |
Also, #325 added a |
Maintainer's notes
cobalt publish
I know this is possible and I'm trying to see where it could fit in. But is this something that would even be wanted as a feature? Adding a custom tag as described in liquid rust for these things I think would be awesome.
I'm going to try implementing this on my own but wanted an idea of if this is planned anyway or explicitly not wanted.
Thanks!
The text was updated successfully, but these errors were encountered: