@@ -36,15 +36,23 @@ class Category extends ContentModelEntryNode {
3636 }
3737 }
3838
39- static serialize ( category ) {
40- return {
39+ static serialize ( category , entriesAlias , categoriesAlias ) {
40+ const data = {
4141 ...category ,
4242 facets : category . facets . map ( models . facet ( ) . serialize ) ,
4343 posts : category . subtree . posts ,
4444 levelPosts : category . subtree . levelPosts ,
4545 categories : category . subtree . categories ,
4646 attachments : category . subtree . attachments
4747 }
48+
49+ if ( entiresAlias ) {
50+ data [ entriesAlias ] = data . posts
51+ }
52+
53+ if ( categoriesAlias ) {
54+ data [ entriesAlias ] = data . categories
55+ }
4856 }
4957
5058 static draftCheck ( mode , node ) {
@@ -63,21 +71,24 @@ class Category extends ContentModelEntryNode {
6371 contentType : context . peek ( ) . categoryContentType ,
6472 categoryContentType : context . peek ( ) . categoryContentType ,
6573 entryContentType : context . peek ( ) . entryContentType ,
74+ categoryAlias : context . peek ( ) . categoryAlias ,
6675 entryAlias : context . peek ( ) . entryAlias ,
76+ categoriesAlias : context . peek ( ) . categoriesAlias ,
77+ entriesAlias : context . peek ( ) . entriesAlias ,
6778 facetKeys : context . peek ( ) . facetKeys || [ ] ,
6879 facets : [ ] ,
6980 sortBy : context . peek ( ) . sortBy ,
7081 sortOrder : context . peek ( ) . sortOrder ,
82+ title,
83+ slug,
7184 content : '' ,
7285 contentRaw : '' ,
73- slug,
74- title,
7586 isDefaultCategory : true ,
7687 level : this . settings . level
7788 }
7889
7990 if ( entriesAlias ) {
80- defaultCategory [ entriesAlias ] = defaultCategory . posts
91+ defaultCategory [ entriesAlias ] = defaultCategory . levelPosts . posts
8192 }
8293
8394 if ( categoriesAlias ) {
@@ -105,10 +116,6 @@ class Category extends ContentModelEntryNode {
105116 }
106117
107118 Object . assign ( this , categoryContext )
108-
109- // TODO: move this stuff along with aliases to serialize
110- this . posts = this . subtree . posts
111- this . attachments = this . subtree . attachments
112119 }
113120
114121 getPermalink ( ) {
@@ -227,7 +234,7 @@ class Category extends ContentModelEntryNode {
227234 )
228235 if ( Category . draftCheck ( this . settings . mode , subCategory ) ) {
229236 tree . categories . push ( subCategory )
230- tree . posts . push ( ...subCategory . posts )
237+ tree . posts . push ( ...subCategory . subtree . posts )
231238 }
232239 return
233240 }
@@ -289,7 +296,7 @@ class Category extends ContentModelEntryNode {
289296 render : async ( { outputPath, pageOfPosts, paginationData } ) => {
290297 const data = {
291298 ...contentModel ,
292- category : Category . serialize ( this ) ,
299+ category : Category . serialize ( this , this . entriesAlias , this . categoriesAlias ) ,
293300 pagination : paginationData ,
294301 posts : pageOfPosts ,
295302 settings,
@@ -299,6 +306,9 @@ class Category extends ContentModelEntryNode {
299306 if ( categoryAlias ) {
300307 data [ categoryAlias ] = data . category
301308 }
309+ if ( this . entriesAlias ) {
310+ data [ this . entriesAlias ] = data . posts
311+ }
302312 return renderer . render ( {
303313 templates : [
304314 `pages/${ this . template } ` ,
0 commit comments