Add automatic page date fallback #2239

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@vbatoufflet
Contributor

Hi,

This PR adds an automatic value for Page.Date using the file's ModTime as fallback when none is provided?

Please let me know if it suits to you.

Regards.

@CLAassistant
CLAassistant commented Jun 27, 2016 edited

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Vincent Batoufflet seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

@bep
Collaborator
bep commented Jun 27, 2016

I guess this is a fair compromise.

@bep bep commented on an outdated diff Jun 27, 2016
hugolib/page.go
@@ -663,6 +664,13 @@ func (p *Page) update(f interface{}) error {
p.Draft = !*published
}
+ if p.Date.IsZero() {
+ fi, err := os.Stat(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), p.File.Path()))
@vbatoufflet
Contributor

Hi,

Thanks for the feedback. I just updated my PR to use hugofs.

@vbatoufflet vbatoufflet Add automatic page date fallback
b6f8ab8
@bep bep added a commit that closed this pull request Jun 28, 2016
@vbatoufflet @bep vbatoufflet + bep Add automatic page date fallback
Closes #2239
eda3678
@bep bep closed this in eda3678 Jun 28, 2016
@luixxiul
luixxiul commented Jul 1, 2016

This causes a trouble if you are using Page in terms of WordPress: about/sitemap/privacy policy/etc which do not have .Date suddenly start to appear in feeds or the list of recent posts.

@vbatoufflet
Contributor

Hi all,

Maybe we can define a configuration option to toggle automatic date feature?

WDYT?

@bep
Collaborator
bep commented Jul 1, 2016 edited

WDYT?

Yes, we need that, and set it to default = false. Could you create a PR?

@luixxiul
luixxiul commented Jul 1, 2016

That would be great!

2016/07/01 16:25 "Bjørn Erik Pedersen" notifications@github.com:

WDYT?

Yes, we need that, and set it to default = false.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@vbatoufflet
Contributor

Yes, I will create a PR.

@vbatoufflet
Contributor

Hi All,

Any suggestion on the setting name, e.g. AutomaticFallbackDates or AutoDates?

@bep
Collaborator
bep commented Jul 6, 2016

@vbatoufflet see my comment on #2244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment