Skip to content

Commit a92643d

Browse files
committed
Update api-ja.js
1 parent cf67c70 commit a92643d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/api-ja.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const fs = require('fs');
22
const path = require('path');
33
const { api: apiOverrides } = require('./data/meta-override.json');
4-
const utils = require('./utils');
54

65
const DEMOS_PATH = path.resolve('static/demos');
76
let 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

Comments
 (0)