11const fs = require ( 'fs' ) ;
22const path = require ( 'path' ) ;
33const { api : apiOverrides } = require ( './data/meta-override.json' ) ;
4- const utils = require ( './utils' ) ;
54
65const DEMOS_PATH = path . resolve ( 'static/demos' ) ;
76let COMPONENT_LINK_REGEXP ;
87
98( async function ( ) {
109 try {
10+ // Dynamic import for ES module utils
11+ const utils = await import ( './utils.mjs' ) ;
12+
1113 const response = await fetch (
1214 'https://raw.githubusercontent.com/ionic-team/ionic-docs/translation/jp/scripts/data/translated-api.json'
1315 ) ;
@@ -23,15 +25,15 @@ let COMPONENT_LINK_REGEXP;
2325 // matches all relative markdown links to a component, e.g. (../button)
2426 COMPONENT_LINK_REGEXP = new RegExp ( `\\(../(${ names . join ( '|' ) } )/?(#[^)]+)?\\)` , 'g' ) ;
2527
26- components . map ( writePage ) ;
28+ components . map ( ( page ) => writePage ( page , utils ) ) ;
2729 } catch ( error ) {
2830 console . error ( 'Error in api-ja script:' , error . message ) ;
2931 }
3032} ) ( ) ;
3133
32- function writePage ( page ) {
34+ function writePage ( page , utils ) {
3335 let data = [
34- renderFrontmatter ( page ) ,
36+ renderFrontmatter ( page , utils ) ,
3537 renderReadme ( page ) ,
3638 renderUsage ( page ) ,
3739 renderProperties ( page ) ,
@@ -49,7 +51,7 @@ function writePage(page) {
4951 fs . writeFileSync ( filePath , data ) ;
5052}
5153
52- function renderFrontmatter ( { tag } ) {
54+ function renderFrontmatter ( { tag } , utils ) {
5355 const frontmatter = {
5456 title : tag ,
5557 } ;
0 commit comments