I have a aws lambda function which calls the eleventy.write() or eleventy.toJSON() method but can't seem to make it work. I have tried different project structures and setting different paths but it either returns an empty array or it throws the following error
TemplateLayoutPathResolver directory does not exist for filename.njk: _includes
When I run the eleventy
command from terminal, it builds successfully.
This is my 11ty project structure
project root folder
-- public (output of the eleventy build)
-- .eleventy.js
-- src (input for the eleventy build)
|-- _data
|-- _includes
my .eleventy.js file looks like this:
...
return {
dir:{
input: 'src',
output: 'public',
},
};
On the lambda function project, where the write()
call is made, I have tried setting the input path relative to the file, then I tried putting the 11ty root folder next to the .js file and instantiating eleventy like let eleventy = new Eleventy(".", "public")
which didn't worked and I also tried taking the content of the eleventy root project and placing it next to the .js file I am making the write()
call.
Also tried setting the configPath like so
let eleventy = new Eleventy(".", "public", {
configPath: "./.eleventy.js",
});
but still not working.
The documentation for the eleventy programmatic API (https://www.11ty.dev/docs/programmatic/) is pretty thin, so any help will be greatly appreciated.