You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 26, 2025. It is now read-only.
✅ This functionality is now available in Eleventy v3 core and doesn’t require any additional configuration — just use the js or javascript front matter type! This repo is specifically for Eleventy v2.
A demo showing how to use free-form JavaScript in front matter to populate the data cascade.
Check out page.njk for a Nunjucks example but this will work in any Eleventy template type (including Custom ones).
Example
---javascriptconstmyString="Hi";// export a functionfunctionmyFunction(){}---
<!-- The template content goes here -->
<div>{{ myString }}</div><div>{{ myFunction()}}</div>
More Advanced Examples
---javascript// async-friendlyconstmyAsyncString=awaitPromise.resolve("HELLO FROM THE OTHER SIDE");// export via destructuring assignmentconst{ myKey }={myKey: "myValue"};const[first,second]=["first","second"];// export via dynamic importconst{ noop }=awaitimport("@zachleat/noop");// access Node.js globals like console.logconsole.log({ noop });---
<!-- The template content goes here -->
About
Demo of free-form JavaScript in front matter to populate the Data Cascade.