File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
import * as fs from 'node:fs' ;
2
2
import * as path from 'node:path' ;
3
3
import * as url from 'node:url' ;
4
+ import prettier from 'prettier' ;
4
5
import stripIndent from 'common-tags/lib/stripIndent/index.js' ;
5
6
6
7
const __filename = url . fileURLToPath ( import . meta. url ) ;
7
8
const __dirname = path . dirname ( __filename ) ;
9
+ const prettierConfig = prettier . resolveConfig . sync ( __dirname ) ;
8
10
9
11
// Preview
10
12
// =============================================================================
@@ -27,9 +29,14 @@ function generatePreview() {
27
29
. replace ( / ( < \/ t i t l e > ) / , ' (Preview)$1' )
28
30
// Replace CDN URLs with local paths
29
31
. replace ( / \/ \/ c d n .j s d e l i v r .n e t \/ n p m \/ d o c s i f y @ 4 \/ / g, '/' ) ;
32
+ const formattedHTML = prettier . format ( outHTML , {
33
+ ...prettierConfig ,
34
+ filepath : outFile ,
35
+ } ) ;
30
36
31
37
console . log ( `\nBuilding ${ outFile } in ${ outPath } ` ) ;
32
- fs . writeFileSync ( path . resolve ( outPath , outFile ) , outHTML ) ;
38
+
39
+ fs . writeFileSync ( path . resolve ( outPath , outFile ) , formattedHTML ) ;
33
40
}
34
41
35
42
generatePreview ( ) ;
You can’t perform that action at this time.
0 commit comments