Multiple templates sharing one data file with external fetch #3405
Unanswered
trevorshannon
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a site that pulls most of its data from an external API (Airtable) at build time. To use that data in my templates, I have a few
*.11tydata.js
files to make the actual API calls and cache the data so that we're not continuously hitting that API on every file save during development.Some of the javascript data files are in the global
_data
directory, but others are directory data files. The problem I'm running into involves one of the directories that has three template files in it (plus a directory data file). Each of the three template files runs the javascript code in the directory data file, so I end up calling the API three times in quick succession for each build that requires a cache refresh. I also end up with three cache entries containing the same data.I originally structured things this way so that I have only those data files required for the serverless bits of my site in the global data dir. That way the serverless page loads are as quick as possible. The other directory data files are used only at build time.
Am I missing something here? What's the recommended way to use directory data files with multiple templates?
Beta Was this translation helpful? Give feedback.
All reactions