Quick Tip: Transform Global Data using an `eleventyComputed.js` Global Data File
You can generate multiple data cascade elements in one eleventyComputed.js file. Following is a working example.
This example generates data cascade elements from multiple .json files in the global data directory.
Assume you have data files named links.json and copyrights.json, and you only want to extract a portion of the json object. In this case, the entry element contains the useful data in the json object, and is a child of the feed element in this case.
The corresponding eleventyComputed.js file contents can look like the following:
_data/eleventyComputed.js
export default {
myCopyrights: (data) => {
return data.copyrights.feed.entry;
},
myLinks: (data) => {
return data.links.feed.entry;
},
};
module.exports = {
myCopyrights: (data) => {
return data.copyrights.feed.entry;
},
myLinks: (data) => {
return data.links.feed.entry;
},
};
All Quick Tips
- Quick Tip: Inline Minified CSS
- Quick Tip: Add Edit on GitHub Links to All Pages
- Quick Tip: Inline Minified JavaScript
- Quick Tip: Zero Maintenance Tag Pages for your Blog
- Quick Tip: Super Simple CSS Concatenation
- Quick Tip: Adding a 404 Not Found Page to your Static Site
- Quick Tip: Fetch GitHub Stargazers Count (and More) at Build Time
- Quick Tip: Trigger a Netlify Build Every Day
- Quick Tip: Cache Data Requests
- Quick Tip: Transform Global Data using an `eleventyComputed.js` Global Data File
- Quick Tip: Use local plugins to reduce config file size
- Quick Tip: Draft Posts using Computed Data
- View all of the Eleventy Quick Tips.
