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 {
|
return {
|
||||||
title: bookData.title,
|
title,
|
||||||
|
subtitle,
|
||||||
description: bookData.description,
|
description: bookData.description,
|
||||||
authors,
|
authors,
|
||||||
series,
|
series,
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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) {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue