Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blending a collection from data and files #617

Open
gerwitz opened this issue Jul 19, 2019 · 4 comments
Open

Blending a collection from data and files #617

gerwitz opened this issue Jul 19, 2019 · 4 comments

Comments

@gerwitz
Copy link

gerwitz commented Jul 19, 2019

I think I want to combine the two approaches discussed in #546. I'm hoping someone here can help me figure out how this is possible:

I have a collection of numbered template files, let's say:

list/
    3.md
    4.md

I wish to output a complete list of pages with a larger range, e.g. 1–5. Pages such as 2 that don't have a matching file would have default content (this is easy enough with the layout). In reality, there are thousands so I don't want to pre-create dummy template files.

So my hope is to create a Javascript "data" file that generates dummy templates, then merge the resulting collection with the extant template files. Or merge them from within the Javascript data file itself, though I don't think it has access to the right context scope.

Alternatively, I would like to create template entities on the fly within .addCollection().

Any tips or ideas are welcome!

@gerwitz
Copy link
Author

gerwitz commented Jul 19, 2019

My last-resort workaround is similar to what @MadeByMike did for #587 … so maybe this is a duplicate.

I have also explored the flip side: adding a collection to the returned results of a Javascript data file. Then I run into something akin to #437 because I cannot access collections.

@gerwitz
Copy link
Author

gerwitz commented Jul 30, 2019

I’ve tried iterating through a range (1–3000) and using .getFilteredByGlob() to weave in existing pages … but performance was abysmal.

So far it seems that generating files for the missing numbers with a gulp task is actually faster than any “smart” solution I’ve tried. But this feels icky so I continue to experiment.

@gerwitz
Copy link
Author

gerwitz commented Oct 21, 2019

For the record, I created a minimal case here: https://github.com/gerwitz/eleventy-sparse-collection

@gerwitz
Copy link
Author

gerwitz commented Jan 12, 2023

This would be trivial to implement with "virtual templates" #1612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant