Closed macdermott closed 2 years ago
@macdermott,
Thank you for the issue! If I understand it correctly, you are proposing a change of the actual underlying model defined by the Delivery SDK
(https://github.com/kontent-ai/delivery-sdk-js) which would 'separate' subpages elements from the 'elements' section to its own property?
Yes, that is correct. Ideally the models generated would separate out elements and subpages and the delivery SDK would be modified accordingly
I've got the same issue. I don't think the delivery SDK needs modification. It would make sense when subpages are part of the model under elements.
My Homepage 'Content model' has:
The generated file: export type Homepage = IContentItem
only has:
I've added the support for subpages
element to the generator and released it under 5.4.0
.
We are not planning on modifying the Delivery model to separate the subpages elements completely as it would bring inconsistency between other SDKs and elements. It should be fairly easy to programmatically find the subpages element by filtering based on the type.
Hi @Enngage, thanks for the quick response!
Now I get the following error:
Cannot find name 'Page'.
* Codename: subpages
*/
subpages: Elements.LinkedItemsElement<Page>;
It seems like the types in subpages
(e.g. 'Page') are not imported as modules.
@Freekbron, oh, you're right, sorry :) I've released a fix for that.
@Enngage Thanks, all working now!
Motivation
Generated models for pages and the homepage do not explicitly reference subpages
Proposed solution
Subpages of a model can be accessed via model.subpages
Additional context
I know that subpages can currently be accessed via linkedItems, but explicitly separating out subpages helps when trying to build a hierarchical structure in a site generator