File tree Expand file tree Collapse file tree 3 files changed +26
-16
lines changed
Expand file tree Collapse file tree 3 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -7896,12 +7896,17 @@ function format_api(
78967896 directory ,
78977897 name
78987898) {
7899- const {
7900- content,
7901- metadata : { title } ,
7902- } = name
7903- ? { content : markdown , metadata : { title : name } }
7904- : extract_frontmatter ( markdown ) ;
7899+ let content ;
7900+ let title ;
7901+
7902+ try {
7903+ const fm = extract_frontmatter ( markdown ) ;
7904+ content = fm . content ;
7905+ title = fm . metadata . title ;
7906+ } catch ( e ) {
7907+ content = markdown ;
7908+ title = name ;
7909+ }
79057910
79067911 const section_slug = make_slug ( title ) ;
79077912
@@ -7911,7 +7916,7 @@ function format_api(
79117916 sections = [ ] ;
79127917 section_stack = [ sections ] ;
79137918 block_open = false ;
7914- section_title = name ? "" : title ;
7919+ section_title = title ;
79157920
79167921 const html = marked_1 ( content , { renderer } ) ;
79177922
@@ -8070,7 +8075,7 @@ async function run() {
80708075 console . log ( base_docs ) ;
80718076 if ( base_docs ) {
80728077 const formatted_base_docs = base_docs . docs . map ( ( [ name , content ] ) =>
8073- format_api ( name , content , "docs" )
8078+ format_api ( name , content , "docs" , name )
80748079 ) ;
80758080 console . log ( JSON . stringify ( formatted_base_docs , null , 2 ) ) ;
80768081
Original file line number Diff line number Diff line change @@ -115,12 +115,17 @@ export function format_api(
115115 directory : string ,
116116 name ?: string
117117) : FormattedFile {
118- const {
119- content,
120- metadata : { title } ,
121- } = name
122- ? { content : markdown , metadata : { title : name } }
123- : extract_frontmatter ( markdown ) ;
118+ let content ;
119+ let title ;
120+
121+ try {
122+ const fm = extract_frontmatter ( markdown ) ;
123+ content = fm . content ;
124+ title = fm . metadata . title ;
125+ } catch ( e ) {
126+ content = markdown ;
127+ title = name ;
128+ }
124129
125130 const section_slug = make_slug ( title ) ;
126131
@@ -130,7 +135,7 @@ export function format_api(
130135 sections = [ ] ;
131136 section_stack = [ sections ] ;
132137 block_open = false ;
133- section_title = name ? "" : title ;
138+ section_title = title ;
134139
135140 const html = marked ( content , { renderer } ) ;
136141
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ async function run() {
118118 console . log ( base_docs ) ;
119119 if ( base_docs ) {
120120 const formatted_base_docs = base_docs . docs . map ( ( [ name , content ] ) =>
121- format_api ( name , content , "docs" )
121+ format_api ( name , content , "docs" , name )
122122 ) ;
123123 console . log ( JSON . stringify ( formatted_base_docs , null , 2 ) ) ;
124124
You can’t perform that action at this time.
0 commit comments