1
- const fetch = require ( 'node-fetch' ) ;
2
- const fs = require ( 'fs' ) ;
3
- const path = require ( 'path' ) ;
4
- const { api : apiOverrides } = require ( './data/meta-override.json' ) ;
5
- const utils = require ( './utils' ) ;
1
+ import { resolve , join } from 'node:path' ;
2
+ import fetch from 'node-fetch' ;
3
+ import { existsSync , writeFileSync } from 'fs' ;
4
+ import overrides from './data/meta-override.json' with { type : 'json' } ;
5
+ import * as utils from './utils.mjs' ;
6
6
7
- const DEMOS_PATH = path . resolve ( 'static/demos' ) ;
7
+ const apiOverrides = overrides . api ;
8
+
9
+ const DEMOS_PATH = resolve ( 'static/demos' ) ;
8
10
let COMPONENT_LINK_REGEXP ;
9
11
10
12
( async function ( ) {
@@ -37,7 +39,7 @@ function writePage(page) {
37
39
data = data . replace ( COMPONENT_LINK_REGEXP , '($1.md$2)' ) ;
38
40
39
41
const path = `i18n/ja/docusaurus-plugin-content-docs/current/api/${ page . tag . slice ( 4 ) } .md` ;
40
- fs . writeFileSync ( path , data ) ;
42
+ writeFileSync ( path , data ) ;
41
43
}
42
44
43
45
function renderFrontmatter ( { tag } ) {
@@ -46,7 +48,7 @@ function renderFrontmatter({ tag }) {
46
48
} ;
47
49
48
50
const demoPath = `api/${ tag . slice ( 4 ) } /index.html` ;
49
- if ( fs . existsSync ( path . join ( DEMOS_PATH , demoPath ) ) ) {
51
+ if ( existsSync ( join ( DEMOS_PATH , demoPath ) ) ) {
50
52
frontmatter . demoUrl = `/docs/demos/${ demoPath } ` ;
51
53
frontmatter . demoSourceUrl = `https://github.com/ionic-team/ionic-docs/tree/main/static/demos/${ demoPath } ` ;
52
54
}
@@ -64,6 +66,16 @@ ${utils.getHeadTag(apiOverrides[tag])}
64
66
}
65
67
66
68
function renderReadme ( { readme, encapsulation } ) {
69
+ if ( ! readme ) {
70
+ return `
71
+ import EncapsulationPill from '@components/page/api/EncapsulationPill';
72
+
73
+ ${ encapsulation !== 'none' ? `<EncapsulationPill type="${ encapsulation } " />` : '' }
74
+
75
+
76
+ ` ;
77
+ }
78
+
67
79
const endIndex = readme . indexOf ( '\n' ) ;
68
80
69
81
const title = readme . substring ( 0 , endIndex ) ;
0 commit comments