1414 * limitations under the License.
1515 */
1616
17- import { BuilderStrategy , BuildResult , BuildTypeContexts , ExportRestDocumentBuildConfig } from '../types'
17+ import {
18+ BuilderStrategy ,
19+ BuildResult ,
20+ BuildTypeContexts ,
21+ ExportDocument ,
22+ ExportRestDocumentBuildConfig ,
23+ } from '../types'
1824import { getDocumentTitle , getSplittedVersionKey } from '../utils'
19- import { createCommonStaticExportDocuments , createSingleFileExportName } from '../utils/export'
25+ import {
26+ createCommonStaticExportDocuments ,
27+ createSingleFileExportName ,
28+ createUnknownExportDocument , generateIndexHtmlPage ,
29+ } from '../utils/export'
2030import { createRestExportDocument } from '../apitypes/rest/rest.document'
2131import { FILE_FORMAT_HTML } from '../consts'
2232
@@ -26,7 +36,7 @@ export class ExportRestDocumentStrategy implements BuilderStrategy {
2636 const { rawDocumentResolver, templateResolver, packageResolver } = builderContext ( config )
2737 const { packageId, version : versionWithRevision , documentId, format, allowedOasExtensions } = config
2838 const [ version ] = getSplittedVersionKey ( versionWithRevision )
29-
39+ const generatedHtmlExportDocuments : ExportDocument [ ] = [ ]
3040 const file = await rawDocumentResolver (
3141 versionWithRevision ,
3242 packageId ,
@@ -36,7 +46,9 @@ export class ExportRestDocumentStrategy implements BuilderStrategy {
3646 buildResult . exportDocuments . push ( await createRestExportDocument ( file . name , await file . text ( ) , format , packageName , version , templateResolver , allowedOasExtensions ) )
3747
3848 if ( format === FILE_FORMAT_HTML ) {
49+ const readme = await buildResult . exportDocuments . find ( ( { filename } ) => filename . toLowerCase ( ) === 'readme.md' ) ?. data . text ( )
3950 buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageName , version , templateResolver , buildResult . exportDocuments [ 0 ] . filename ) )
51+ buildResult . exportDocuments . push ( createUnknownExportDocument ( 'index.html' , await generateIndexHtmlPage ( packageName , version , generatedHtmlExportDocuments , templateResolver , readme ) ) )
4052 buildResult . exportFileName = createSingleFileExportName ( packageId , version , getDocumentTitle ( file . name ) , 'zip' )
4153 return buildResult
4254 }
0 commit comments