@@ -351,25 +351,37 @@ async function mergeExecutedFiles(
351351 file . executeResult . markdown ,
352352 ) ;
353353
354- const yaml = partitioned ?. yaml
355- ? readYamlFromMarkdown ( partitioned ?. yaml )
356- : undefined ;
357- const frontTitle = frontMatterTitle ( yaml ) ;
358- const titleMarkdown = frontTitle ? `# ${ frontTitle } \n\n` : "" ;
359-
360- const titleBlockPath = resourcePath (
361- "projects/book/pandoc/title-block.md" ,
362- ) ;
363- const titleAttr = `template='${ titleBlockPath } '` ;
364-
365- const titleBlockMd = partitioned ?. yaml
366- ? "```````{.quarto-title-block " + titleAttr + "}\n" +
367- partitioned ?. yaml +
368- "\n```````"
369- : "" ;
354+ const titleMdFromFrontMatter = ( frontMatter ?: string ) => {
355+ const yaml = frontMatter
356+ ? readYamlFromMarkdown ( frontMatter )
357+ : undefined ;
358+
359+ if ( yaml ) {
360+ const frontTitle = frontMatterTitle ( yaml ) ;
361+ if ( frontTitle ) {
362+ const titleMarkdown = frontTitle ? `# ${ frontTitle } \n\n` : "" ;
363+
364+ const titleBlockPath = resourcePath (
365+ "projects/book/pandoc/title-block.md" ,
366+ ) ;
367+ const titleAttr = `template='${ titleBlockPath } '` ;
368+
369+ const titleBlockMd = "```````{.quarto-title-block " +
370+ titleAttr + "}\n" +
371+ partitioned ?. yaml +
372+ "\n```````" ;
373+
374+ return titleMarkdown + titleBlockMd ;
375+ } else {
376+ return "" ;
377+ }
378+ } else {
379+ return "" ;
380+ }
381+ } ;
370382
371- itemMarkdown = bookItemMetadata ( project , item , file ) + titleMarkdown +
372- titleBlockMd +
383+ itemMarkdown = bookItemMetadata ( project , item , file ) +
384+ titleMdFromFrontMatter ( partitioned ?. yaml ) +
373385 ( partitioned ?. markdown || file . executeResult . markdown ) ;
374386 } else {
375387 throw new Error (
0 commit comments