@@ -12,19 +12,19 @@ let COMPONENT_LINK_REGEXP;
12
12
const response = await fetch (
13
13
'https://raw.githubusercontent.com/ionic-team/ionic-docs/translation/jp/scripts/data/translated-api.json' ,
14
14
) ;
15
-
15
+
16
16
if ( ! response . ok ) {
17
17
console . error ( `Failed to fetch translated API data: ${ response . status } ${ response . statusText } ` ) ;
18
18
return ;
19
19
}
20
-
20
+
21
21
const data = await response . json ( ) ;
22
-
22
+
23
23
if ( ! data || ! data . components ) {
24
24
console . error ( 'Invalid API data structure - missing components' ) ;
25
25
return ;
26
26
}
27
-
27
+
28
28
const { components } = data ;
29
29
30
30
const names = components . map ( ( component ) => component . tag . slice ( 4 ) ) ;
@@ -57,13 +57,13 @@ function writePage(page) {
57
57
data = data . replace ( COMPONENT_LINK_REGEXP , '($1.md$2)' ) ;
58
58
59
59
const filePath = `i18n/ja/docusaurus-plugin-content-docs/current/api/${ page . tag . slice ( 4 ) } .md` ;
60
-
60
+
61
61
// Ensure directory exists
62
62
const dir = path . dirname ( filePath ) ;
63
63
if ( ! fs . existsSync ( dir ) ) {
64
64
fs . mkdirSync ( dir , { recursive : true } ) ;
65
65
}
66
-
66
+
67
67
fs . writeFileSync ( filePath , data ) ;
68
68
} catch ( error ) {
69
69
console . error ( `Error writing page for ${ page . tag } :` , error ) ;
@@ -99,15 +99,15 @@ function renderReadme(page) {
99
99
console . warn ( `Missing readme for component: ${ page ?. tag || 'unknown' } ` ) ;
100
100
return '' ;
101
101
}
102
-
102
+
103
103
const readme = page . readme ;
104
104
const endIndex = readme . indexOf ( '\n' ) ;
105
-
105
+
106
106
// Add additional safety check
107
107
if ( endIndex === - 1 ) {
108
108
return readme ; // Return the whole readme if no newline found
109
109
}
110
-
110
+
111
111
const title = readme . substring ( 0 , endIndex ) ;
112
112
const rest = readme . substring ( endIndex ) ;
113
113
0 commit comments