Eleventy Cloud Demo
Running Eleventy inside of a Netlify serverless function.
Run it
Locally
Requires netlify-cli
for local testing, run npm install netlify-cli -g
.
- Run
npm start
- Navigate to the demo URL at
http://localhost:8888/.netlify/functions/cloud?name=ZAAAACH
Production
- Deploy to Netlify
- There are no other steps
😅
How it works
- Use Eleventy as normal.
- In this demo
src
is the input directory. - For this demo we include one Nunjucks template (
./src/sample-nunjucks.njk
), a Global Data file, an include template, and an Eleventy layout.
- In this demo
./netlify/functions/cloud.js
is the code for running Eleventy in the serverless function.- This requires Eleventy 1.0. this demo is currently using a Canary build. Be careful here, Canary is considered unstable! Don’t use it in production.
./netlify/functions/cloud.js
compiles and renders./src/sample-nunjucks.njk
at request time and sets query parameters as Global Data in Eleventy’s cascade.
bundle.sh
automates bundling your build’s code into the serverless function for deployment. It puts files into your./netlify/functions/cloud/
directory.