generated from tpl/obsidian-sample-plugin
Get subtitle and add indent helper to templater
This commit is contained in:
parent
f8e544d381
commit
92008c0070
|
@ -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,
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface Series {
|
|||
|
||||
export interface Book {
|
||||
title: string;
|
||||
subtitle: string;
|
||||
description: string;
|
||||
authors: Author[];
|
||||
series: Series | null;
|
||||
|
|
|
@ -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) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue