@@ -241,7 +241,7 @@ export class PugPrinter {
241241 private readonly content : string ,
242242 private tokens : Token [ ] ,
243243 private readonly options : PugPrinterOptions ,
244- private frontmatter : Frontmatter < string > ,
244+ private readonly frontmatter : Frontmatter < string > ,
245245 ) {
246246 this . frontmatter = frontmatter ;
247247 this . indentString = options . pugUseTabs
@@ -391,10 +391,14 @@ export class PugPrinter {
391391 token = this . getNextToken ( ) ;
392392 }
393393
394- const fm = await this . frontmatterFormat ( this . frontmatter . value ) ;
395- const formattedFrontmatter = this . frontmatter ? '---\n' + fm + '---\n' : '' ;
394+ if ( this . frontmatter ) {
395+ const frontmatter : string = await this . frontmatterFormat (
396+ this . frontmatter . value ,
397+ ) ;
398+ results . unshift ( '---\n' , frontmatter , '---\n' ) ;
399+ }
396400
397- return formattedFrontmatter + results . join ( '' ) ;
401+ return results . join ( '' ) ;
398402 }
399403
400404 private getNextToken ( ) : Token | null {
@@ -483,12 +487,14 @@ export class PugPrinter {
483487 }
484488
485489 private async frontmatterFormat ( frontmatter : string ) : Promise < string > {
486- const options = {
490+ const options : Options = {
487491 parser : 'yaml' ,
488492 collectionStyle : 'block' ,
489493 } ;
490494
491- return format ( frontmatter , options ) ;
495+ const result : string = await format ( frontmatter , options ) ;
496+
497+ return result ;
492498 }
493499
494500 private async frameworkFormat ( code : string ) : Promise < string > {
0 commit comments