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 { return {
title: bookData.title, title,
subtitle,
description: bookData.description, description: bookData.description,
authors, authors,
series, series,

View File

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

View File

@ -16,6 +16,15 @@ Handlebars.registerHelper("normalizeDesc", (desc: string) => {
return desc.replace(/(\r\n|\n|\r)/gm, " ").trim(); 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 { export class Templater {
public constructor(private readonly app: App) {} public constructor(private readonly app: App) {}