diff --git a/src/data-sources/Goodreads.ts b/src/data-sources/Goodreads.ts index 18fe0c2..1eccb87 100644 --- a/src/data-sources/Goodreads.ts +++ b/src/data-sources/Goodreads.ts @@ -169,8 +169,18 @@ export class Goodreads { }; } + let title = bookData.title; + let subtitle = ""; + + if (title.includes(": ")) { + const parts = title.split(": "); + subtitle = parts.pop()!; + title = parts.join(": "); + } + return { - title: bookData.title, + title, + subtitle, description: bookData.description, authors, series, diff --git a/src/types.ts b/src/types.ts index ad683b5..43d70c4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,6 +14,7 @@ export interface Series { export interface Book { title: string; + subtitle: string; description: string; authors: Author[]; series: Series | null; diff --git a/src/utils/Templater.ts b/src/utils/Templater.ts index 5e18127..132033f 100644 --- a/src/utils/Templater.ts +++ b/src/utils/Templater.ts @@ -16,6 +16,15 @@ Handlebars.registerHelper("normalizeDesc", (desc: string) => { return desc.replace(/(\r\n|\n|\r)/gm, " ").trim(); }); +Handlebars.registerHelper("indent", (text: string, indent = " ") => { + return new Handlebars.SafeString( + text + .split("\n") + .map((line) => indent + line) + .join("\n") + ); +}); + export class Templater { public constructor(private readonly app: App) {}