Skip to content

Commit

Permalink
Merge pull request #6 from KentarouTakeda/v1
Browse files Browse the repository at this point in the history
Merge v1 branch
  • Loading branch information
KentarouTakeda authored Dec 28, 2023
2 parents e2efd96 + bc947d0 commit ee4c845
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ let plantUMLServer: PlantUMLServer | null = null;
let libConfig: LibConfig | null = null;
let classConfig: ClassConfig | null = null;

const mergeConfig = (
defaultConfig: PluginConfig,
config: Partial<PluginConfig>,
): PluginConfig => ({
...defaultConfig,
...Object.fromEntries(
Object.entries(config).filter((_, value) => null != value),
),
});

export const hooks = {
init: function (this: any) {
const mergedConfig = Object.assign(
{},
defaultConfig,
this.config.get('pluginsConfig.plantuml-server') as PluginConfig,
const mergedConfig = mergeConfig(defaultConfig, {
...this.config.get('pluginsConfig.plantuml-server'),
// ebook-convert cannot handle svg format data-uri, so it is forced to change to png
this.output.name === 'ebook' ? { format: 'png' } : {},
);
...(this.output.name === 'ebook' ? { format: 'png' } : {}),
});

libConfig = {
optimizeImage: mergedConfig.optimizeImage,
Expand Down

0 comments on commit ee4c845

Please sign in to comment.