-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Directory Data File in Top Level Input Directory is not parsed #935
Comments
Looking through the documentation I don’t think we need to change anything here. To me https://www.11ty.dev/docs/data-template-dir/ already suggests this behavior even though it leaves off variations based on |
If anyone finds instances of things that do need changes, let me know! |
Maybe you are correct, but I think there are two issues to consider. The first issue is efficiency in building a site. If a site is using pagination to display 10 items per page that are obtained from a REST service that returns 200 items, the REST service will be invoked 20 times every time the site is built UNLESS that data source is global. The second issues is the possibility that one of those REST calls might return different data because data was added to or deleted from a database that the REST service queries while the site was being built. That could result in publishing an inconsistent site. I can imagine not wanting to make the data global because it is only used by a subset of the site. |
@mvolkmann, grab the API data once in function getEndpoint = function(options) {
// Call an endpoint and return a response
}
const host = 'https://example.com'
module.exports = function (eleventyConfig) {
eleventyConfig.addCollection('articles', async collection => {
const response = await getEndpoint({ url: host + '/api/articles' })
return response.data
})
} |
Say I am using
eleventy --input=docs
and have adocs/docs.11tydata.js
data file. Currently this file is not included in the data cascade. While this is very much related to #245, to me this is more of a bug.#245 handles the use case when the folder for data file naming is out of the project scope (and may be different from project to project clone). This issue is specific to an explicit input directory.
The text was updated successfully, but these errors were encountered: