-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
TemplateContentPrematureUseError for one specific post / date, only on start #3630
Comments
OK this is spooky, if I change to It only works with future dates. Even tomorrow. |
Edit: it came back on a later run, so this didn't actually fix it. I think it was due to the use of .getAllSorted() when adding my posts collection.
eleventyConfig.addCollection("posts", function (collectionsApi) {
const isPost = (item) => {
const dir = item.filePathStem.split("/");
const extension = item.inputPath.split(".").pop();
return !item.data.isIndex && dir.length >= 3 && extension === "md";
};
return collectionsApi.getAllSorted().filter(isPost);
}); Changing to .getAll() seems to fix it. eleventyConfig.addCollection("posts", function (collectionsApi) {
const isPost = (item) => {
const dir = item.filePathStem.split("/");
const extension = item.inputPath.split(".").pop();
return !item.data.isIndex && dir.length >= 3 && extension === "md";
};
return collectionsApi
.getAll()
.filter(isPost)
.sort((a, b) => a.date - b.date);
}); |
Disabling I have It must have something to do with the way that I set up the posts collection. |
I renamed my custom posts collection to "my-posts" and used that in the feed plugin, and it starts now without the error. |
One more issue: this post was the only one with .11ty-data.json. The content:
When I removed that file, reloading was fixed. |
Operating system
macOS 15.2
Eleventy
3.0.0
Describe the bug
Content of that post:
Reproduction steps
I get the error when I first run
npx @11ty/eleventy --serve
(dev). That's the only post that gives that error.If I comment out the data line...
... it will actually start and serve the page, with the file created date. I can then uncomment the
date:
line and it rerenders and fixes the date.It only throws on initial start.
npx @11ty/eleventy
(build) hits the same error.This is different than #3136 because it happens on startup, not rerender.
Expected behavior
No response
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: