fix: do not add a config folder to api path (#1187)

This commit is contained in:
Ihor Karpiuk
2023-07-26 14:37:07 +03:00
committed by GitHub
parent 0976fbabab
commit 2e02eda23b
11 changed files with 113 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ import { Config, isAbsoluteUrl } from '@redocly/openapi-core';
import { renderToString } from 'react-dom/server';
import { ServerStyleSheet } from 'styled-components';
import { compile } from 'handlebars';
import { join } from 'path';
import { dirname, join, resolve } from 'path';
import { existsSync, lstatSync, readFileSync } from 'fs';
import type { BuildDocsOptions } from './types';
@@ -57,9 +57,10 @@ export async function getPageHTML(
templateOptions,
redocOptions = {},
redocCurrentVersion,
}: BuildDocsOptions
}: BuildDocsOptions,
configPath?: string
) {
process.stderr.write('Prerendering docs');
process.stderr.write('Prerendering docs\n');
const apiUrl = redocOptions.specUrl || (isAbsoluteUrl(pathToApi) ? pathToApi : undefined);
const store = await createStore(api, apiUrl, redocOptions);
@@ -72,7 +73,7 @@ export async function getPageHTML(
templateFileName = templateFileName
? templateFileName
: redocOptions?.htmlTemplate
? (redocOptions.htmlTemplate as string)
? resolve(configPath ? dirname(configPath) : '', redocOptions.htmlTemplate)
: join(__dirname, './template.hbs');
const template = compile(readFileSync(templateFileName).toString());
return template({