Get subtitle and add indent helper to templater

This commit is contained in:
Evan Fiordeliso 2025-07-17 09:08:29 -04:00
parent f8e544d381
commit 92008c0070
3 changed files with 21 additions and 1 deletions

View File

@ -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,

View File

@ -14,6 +14,7 @@ export interface Series {
export interface Book {
title: string;
subtitle: string;
description: string;
authors: Author[];
series: Series | null;

View File

@ -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) {}