Skip to content

Commit

Permalink
Merge pull request #5 from KentarouTakeda/omit-null-value-from-book-json
Browse files Browse the repository at this point in the history
fix(config): omit null value from book.json
  • Loading branch information
KentarouTakeda authored Dec 28, 2023
2 parents b6e5c7f + ef50769 commit 3afb871
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 3afb871

Please sign in to comment.