@@ -159,11 +159,25 @@ class MustachePrimitiveWrapper {
159159 }
160160}
161161
162+ class TOCPrimitiveWrapper extends MustachePrimitiveWrapper {
163+ public readonly last : boolean ;
164+ public constructor ( primitive : Primitive , last = false ) {
165+ super ( primitive ) ;
166+ this . last = last ;
167+ }
168+
169+ public static fromPrims ( prims : Array < MustachePrimitiveWrapper > ) : Array < TOCPrimitiveWrapper > {
170+ return prims . map (
171+ ( prim , index ) => new TOCPrimitiveWrapper ( prim . primitive , index === prims . length - 1 ) ,
172+ ) ;
173+ }
174+ }
175+
162176class TableOfContentsSection {
163177 public constructor (
164178 public readonly fullCategoryName : string ,
165179 public readonly shortCategoryName : string ,
166- public readonly prims : Array < MustachePrimitiveWrapper > ,
180+ public readonly prims : Array < TOCPrimitiveWrapper > ,
167181 ) { }
168182
169183 public static fromCategoryName (
@@ -173,7 +187,11 @@ class TableOfContentsSection {
173187 ) : TableOfContentsSection | null {
174188 const prims = unfilteredPrims . filter ( ( prim ) => prim . primitive . tags . includes ( shortCategoryName ) ) ;
175189 if ( prims . length === 0 ) return null ;
176- return new TableOfContentsSection ( fullCategoryName , shortCategoryName , prims ) ;
190+ return new TableOfContentsSection (
191+ fullCategoryName ,
192+ shortCategoryName ,
193+ TOCPrimitiveWrapper . fromPrims ( prims ) ,
194+ ) ;
177195 }
178196}
179197
@@ -194,7 +212,11 @@ class TableOfContents {
194212 . filter ( ( section ) : section is TableOfContentsSection => section !== null ) ;
195213 if ( sections . length === 0 ) {
196214 return new TableOfContents ( [
197- new TableOfContentsSection ( "All Primitives" , "all" , unfilteredPrims ) ,
215+ new TableOfContentsSection (
216+ "All Primitives" ,
217+ "all" ,
218+ TOCPrimitiveWrapper . fromPrims ( unfilteredPrims ) ,
219+ ) ,
198220 ] ) ;
199221 }
200222 return new TableOfContents ( sections ) ;
0 commit comments