@@ -100,26 +100,32 @@ async function fetchPageContent(
100100async function loadSlugMap ( ) : Promise < Map < string , string | null > > {
101101 const mapPath = path . join ( __dirname , "slug_map.json" ) ;
102102 const data = await readFile ( mapPath , "utf8" ) ;
103- const arr = JSON . parse ( data ) as Array < { cppref : string ; cppdoc : string | null } > ;
103+ const arr = JSON . parse ( data ) as Array < {
104+ cppref : string ;
105+ cppdoc : string | null ;
106+ } > ;
104107 const map = new Map < string , string | null > ( ) ;
105108 for ( const entry of arr ) {
106109 map . set ( entry . cppref , entry . cppdoc ) ;
107110 }
108111 return map ;
109112}
110113
111- function replaceDocLinks ( content : string , slugMap : Map < string , string | null > ) : string {
114+ function replaceDocLinks (
115+ content : string ,
116+ slugMap : Map < string , string | null >
117+ ) : string {
112118 const docLinkRegex = / < D o c L i n k \s + ( [ ^ > ] * ) > / g;
113119 return content . replace ( docLinkRegex , ( match , attributes ) => {
114120 const srcMatch = attributes . match ( / s r c \s * = \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / ) ;
115121 if ( ! srcMatch ) {
116122 return match ;
117123 }
118124 const src = srcMatch [ 1 ] ;
119- if ( ! src . startsWith ( '/' ) ) {
125+ if ( ! src . startsWith ( "/" ) ) {
120126 return match ;
121127 }
122- const key = src . slice ( 1 ) . replace ( / \. h t m l $ / , '' ) ;
128+ const key = src . slice ( 1 ) . replace ( / \. h t m l $ / , "" ) ;
123129 const mapped = slugMap . get ( key ) ;
124130 let newSrc : string ;
125131 if ( mapped === undefined ) {
@@ -143,7 +149,7 @@ async function convertToMDX(
143149 "{{LLM_DOCS}}" ,
144150 await readFile (
145151 __dirname +
146- "/../src/content/docs/development/guide/component-docs-for-llm.mdx" ,
152+ "/../src/content/docs/development/guide/component-docs-for-llm.mdx" ,
147153 "utf8"
148154 )
149155 ) ;
@@ -308,7 +314,7 @@ async function writeMDXFile(
308314 await fs . mkdir ( dir , { recursive : true } ) ;
309315 const frontmatter = `---
310316title: ${ JSON . stringify ( title ) }
311- cppref-url: ${ cpprefUrl ? JSON . stringify ( cpprefUrl ) : ' null' }
317+ cppref-url: ${ cpprefUrl ? JSON . stringify ( cpprefUrl ) : " null" }
312318---\n\n` ;
313319 await fs . writeFile ( filePath , frontmatter + content , "utf8" ) ;
314320 console . log ( `Written to ${ filePath } ` ) ;
@@ -509,11 +515,11 @@ async function main() {
509515 if ( res . status !== 0 ) {
510516 throw new Error (
511517 "Build failed, possibly due to issues with the generated MDX:" +
512- res . stderr ?. toString ( ) +
513- res . stdout ?. toString ( ) +
514- res . error ?. toString ( ) +
515- " exit code " +
516- res . status
518+ res . stderr ?. toString ( ) +
519+ res . stdout ?. toString ( ) +
520+ res . error ?. toString ( ) +
521+ " exit code " +
522+ res . status
517523 ) ;
518524 }
519525
0 commit comments