eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

feature: data overlay beside content templates

Open mw75 opened this issue 2 years ago • 3 comments
trafficstars

I would like to keep content separate from metadata.

I thought that could be achieved by putting corresponding data files in the same directory structure under _data as the template is.

For example consider a template located at posts/subdir/my-first-blog-post.md i would like to place metadata in: _data/posts/subdir/my-first-blog-post.11tydata.js _data/posts/subdir/my-first-blog-post.11tydata.json _data/posts/subdir/my-first-blog-post.json _data/posts/subdir/subdir.11tydata.js _data/posts/subdir/subdir.11tydata.json _data/posts/subdir/subdir.json _data/posts/posts.11tydata.js _data/posts/posts.11tydata.json _data/posts/posts.json

I tried to understand the plugin concept to develop a eleventy-overlay-plugin, but it seams a plugin has no more capabilities than configuration. If i misunderstood the concept please point me to the right documentation.

Regards, Mario

mw75 avatar Nov 22 '23 20:11 mw75

In general, you're absolutely correct in two ways.

First: 11ty plugins can do the same thing you can do in configuration(*). Second: the _data directory does not work this way in 11ty, since it's meant for global data that is available in all templates.

BUT: I think you can solve all this "just" by doing a clever trick with computed data! You can use js computed data to use the path of the input template to load a corresponding data file from a directory you decide (I would not place the data in the _data directory!). If I find the time and this is not already hint enough, I can try building a PoC for you.

Snapstromegon avatar Nov 23 '23 16:11 Snapstromegon

I think I already got the idea. But computed data runs to late for setting tags for example. Besides the fact, that it is meant to generate only one value.

For sure you can create a data structure on data.overlay for example, but that would not play nicely with all the existing stuff. Did I miss something?

Thanks and regards, Mario

mw75 avatar Nov 24 '23 09:11 mw75

What does eleventy-overlay-plugin do? I don’t fully understand the use case yet

zachleat avatar Jun 11 '24 22:06 zachleat