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

(Possible) Documentation issue with page.date #900

Open
cfjedimaster opened this issue Feb 4, 2020 · 7 comments
Open

(Possible) Documentation issue with page.date #900

cfjedimaster opened this issue Feb 4, 2020 · 7 comments

Comments

@cfjedimaster
Copy link

Describe the bug
The docs say that page.date will be the file's created date unless overridden. I was testing this and noticed it would update every time I modified the file, acting more like the file modification date than creation.

After speaking with some folks on the tnd Slack, we assumed it was because Eleventy was regenerating the HTML every time I saved the file. So it was the file creation value, but the file was recreated on my edits.

However... when I stopped using eleventy --serve and just output a static version, I'm seeing the same thing. A file I made at time X and modified at Y will show Y in the static output.

Are the docs wrong about the default?

@cfjedimaster
Copy link
Author

@zachleat
Copy link
Member

zachleat commented Feb 4, 2020

I assume you’re referencing https://www.11ty.dev/docs/dates/ specifically:

image

Eleventy currently runs the entire build and transforms all input files and writes all files to the output directory. So yes, the file is being created with every build!

#108 will change this behavior.

@cfjedimaster
Copy link
Author

But I'm not seeing this when I create a build. By what you said, if i run eleventy in my folder now than page.date should be the current time, right? But I'm seeing it use the lastmod value instead.

@zachleat
Copy link
Member

zachleat commented Feb 4, 2020

Are you saying that lastmod and current time are different? I would assume that most of the time (during local dev) they will be the same.

Relevant code:

"getMappedDate: using file created time for %o of %o (from %o)",

Docs: https://nodejs.org/docs/latest-v12.x/api/fs.html#fs_stats_birthtimems

@cfjedimaster
Copy link
Author

So I made a file, docs/banana.md. I made it at 11AM let's say. I edited it at 11:15. While running eleventy --serve, the value I saw was 11:15. That makes sense because when I edited it, Eleventy recreated the file.

However, I stopped running the server, rm -rf _site, run eleventy, and in the generated files, I still see 11:15.

Make sense?

@cfjedimaster
Copy link
Author

To add more context - I have setup my site to deploy to Netlify. In my testing there with 2 docs (both outputting the page.date value), when I edit one and trigger a new deploy, both files have the same output. That makes sense, which makes me think its the lack of a proper "birth" value (see my link above) that could be the issue. When I stat the files in WSL I see no value for birth, but only the lastmod, so maybe Eleventy has to use lastmod on my machine, but on Netlify it can properly use file creation date.

So... maybe only an issue for certain types of *nix installs?

@Ryuno-Ki
Copy link
Contributor

Do you have the stat command available?
That will give you information about a file (atleast on GNU/Linux - perhaps macOS as well).

Otherwise, use fs.stat in a node REPL to check.

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

No branches or pull requests

3 participants