Is there any way to programatically add page objects before any files are processed? #2713
-
|
Say, I have a huge XML file and I wanted to take a set of elements of the file to programmatically create separated pages. I would take care of selecting the portions, generating permalinks & titles (all that stuff that is done with front matter usually). Is there any way to "inject" these kinds of self generated objects, so 11ty creates pages from them. I've looked at Then, there would be the option to preprocess & dump all the parts as part of a huge data file and use pagination to generate pages for that. Is this te only way to go about this? Or can I generate page-like-objects and insert them manually into the data cascade? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Not sure if I understand 100%, but if the question is: "Can i use XML as a data file format?", see https://www.11ty.dev/docs/data-custom/. |
Beta Was this translation helpful? Give feedback.
-
|
I got it to work. Read in my xml file, manually created a collection and added the parts of the xml that I wanted to be on different pages as nodes into the collection. See here: https://www.11ty.dev/docs/collections/#advanced-custom-filtering-and-sorting Then I used the pagination feature and paginated the collection using a size of 1. See: https://www.11ty.dev/docs/pagination/#paging-a-collection I still would prefer if one could create a ton of objects like: And add them through a programmatic API as if it was a file on disc. Since there would be no input path, one had to declare the permalink manually. Anyway it works right now, thanks :) have a great new year |
Beta Was this translation helpful? Give feedback.
I got it to work. Read in my xml file, manually created a collection and added the parts of the xml that I wanted to be on different pages as nodes into the collection. See here: https://www.11ty.dev/docs/collections/#advanced-custom-filtering-and-sorting
Then I used the pagination feature and paginated the collection using a size of 1. See: https://www.11ty.dev/docs/pagination/#paging-a-collection
I still would prefer if one could create a ton of objects like:
And add them through a programmatic API as if it was a file on disc. Since there would be no input path, one had …