diff --git a/packages/oslo-generator-html/lib/HtmlGenerationService.ts b/packages/oslo-generator-html/lib/HtmlGenerationService.ts index 25bbb66..dc6149c 100644 --- a/packages/oslo-generator-html/lib/HtmlGenerationService.ts +++ b/packages/oslo-generator-html/lib/HtmlGenerationService.ts @@ -11,18 +11,18 @@ import { SpecificationType } from './utils/specificationTypeEnum'; export class HtmlGenerationService implements IService { public readonly logger: Logger; public readonly configuration: HtmlGenerationServiceConfiguration; + public dirs: string[] = [resolve(`${__dirname}/templates`)]; public constructor( @inject(ServiceIdentifier.Logger) logger: Logger, @inject(ServiceIdentifier.Configuration) - config: HtmlGenerationServiceConfiguration, + config: HtmlGenerationServiceConfiguration ) { this.logger = logger; this.configuration = config; } public async init(): Promise { - const dirs: string[] = [resolve(`${__dirname}/templates`)]; if (this.configuration.templates) { let templatesPath = this.configuration.templates; @@ -32,25 +32,29 @@ export class HtmlGenerationService implements IService { } const customTemplatesDir: string = resolve(templatesPath); - dirs.push(customTemplatesDir); + this.dirs.push(customTemplatesDir); } - const env = nj.configure(dirs); + const env = nj.configure(this.dirs); env.addGlobal('getAnchorTag', this.getAnchorTag); } public async run(): Promise { + let indexPath: string = ''; const [config, stakeholders, metadata] = await Promise.all([ this.readConfigFile(this.configuration.input), this.readConfigFile(this.configuration.stakeholders), this.readConfigFile(this.configuration.metadata), ]); - const indexPath = - this.configuration.rootTemplate || - (this.configuration.specificationType === SpecificationType.Vocabulary - ? 'voc2.j2' - : 'ap2.j2'); + if (this.configuration.templates && this.configuration.rootTemplate) { + indexPath = `${this.dirs[1]}/${this.configuration.rootTemplate}`; + } else { + indexPath = + this.configuration.specificationType === SpecificationType.Vocabulary + ? `${this.dirs[0]}/voc2.j2` + : `${this.dirs[0]}/ap2.j2`; + } let data: any = {}; diff --git a/packages/oslo-generator-html/package.json b/packages/oslo-generator-html/package.json index f20204b..c1ca938 100644 --- a/packages/oslo-generator-html/package.json +++ b/packages/oslo-generator-html/package.json @@ -1,6 +1,6 @@ { "name": "@oslo-flanders/html-generator", - "version": "0.0.18-alpha.0", + "version": "0.0.19-alpha.0", "description": "Generates an HTML file using an OSLO webuniversum config", "author": "Digitaal Vlaanderen ", "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-html#readme",