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' ;
66
7- const DEMOS_PATH = path . resolve ( 'static/demos' ) ;
7+ const apiOverrides = overrides . api ;
8+
9+ const DEMOS_PATH = resolve ( 'static/demos' ) ;
810let COMPONENT_LINK_REGEXP ;
911
1012( async function ( ) {
@@ -37,7 +39,7 @@ function writePage(page) {
3739 data = data . replace ( COMPONENT_LINK_REGEXP , '($1.md$2)' ) ;
3840
3941 const path = `i18n/ja/docusaurus-plugin-content-docs/current/api/${ page . tag . slice ( 4 ) } .md` ;
40- fs . writeFileSync ( path , data ) ;
42+ writeFileSync ( path , data ) ;
4143}
4244
4345function renderFrontmatter ( { tag } ) {
@@ -46,7 +48,7 @@ function renderFrontmatter({ tag }) {
4648 } ;
4749
4850 const demoPath = `api/${ tag . slice ( 4 ) } /index.html` ;
49- if ( fs . existsSync ( path . join ( DEMOS_PATH , demoPath ) ) ) {
51+ if ( existsSync ( join ( DEMOS_PATH , demoPath ) ) ) {
5052 frontmatter . demoUrl = `/docs/demos/${ demoPath } ` ;
5153 frontmatter . demoSourceUrl = `https://github.com/ionic-team/ionic-docs/tree/main/static/demos/${ demoPath } ` ;
5254 }
@@ -64,6 +66,16 @@ ${utils.getHeadTag(apiOverrides[tag])}
6466}
6567
6668function 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+
6779 const endIndex = readme . indexOf ( '\n' ) ;
6880
6981 const title = readme . substring ( 0 , endIndex ) ;
0 commit comments