@@ -239,4 +239,28 @@ describe('parseApiDoc', () => {
239239 assert . strictEqual ( results . length , 0 ) ;
240240 } ) ;
241241 } ) ;
242+
243+ describe ( 'top-level nodes (YAML frontmatter)' , ( ) => {
244+ it ( 'captures top-level frontmatter in the first entry' , ( ) => {
245+ const tree = u ( 'root' , [
246+ u ( 'yaml' , 'layout: home\ncontributors: [shams]' ) ,
247+ h ( 'First Heading' ) ,
248+ u ( 'paragraph' , [ u ( 'text' , 'First content.' ) ] ) ,
249+ h ( 'Second Heading' , 2 ) ,
250+ u ( 'paragraph' , [ u ( 'text' , 'Second content.' ) ] ) ,
251+ ] ) ;
252+ const results = parseApiDoc ( { path, tree } , typeMap ) ;
253+
254+ assert . strictEqual ( results . length , 2 ) ;
255+
256+ const firstContent = results [ 0 ] . content . children ;
257+ assert . strictEqual ( firstContent . length , 3 ) ;
258+ assert . strictEqual ( firstContent [ 0 ] . type , 'yaml' ) ;
259+ assert . strictEqual ( firstContent [ 1 ] . type , 'heading' ) ;
260+
261+ const secondContent = results [ 1 ] . content . children ;
262+ assert . strictEqual ( secondContent . length , 2 ) ;
263+ assert . strictEqual ( secondContent [ 0 ] . type , 'heading' ) ;
264+ } ) ;
265+ } ) ;
242266} ) ;
0 commit comments