Skip to content

Commit

Permalink
fix: add note variable to the template
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Apr 5, 2023
1 parent 9bbf502 commit ea65aa6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DATE_FORMAT,
formatDate,
getHighlightLocation,
HighlightType,
loadArticles,
PageType,
parseDateTime,
Expand Down Expand Up @@ -268,9 +269,13 @@ export default class OmnivorePlugin extends Plugin {
if (!(omnivoreFolder instanceof TFolder)) {
await this.app.vault.createFolder(folderName);
}
const articleHighlights = article.highlights || [];
// filter out notes and redactions
const articleHighlights =
article.highlights?.filter(
(h) => h.type === HighlightType.Highlight
) || [];
// sort highlights by location if selected in options
highlightOrder === "LOCATION" &&
if (highlightOrder === "LOCATION") {
articleHighlights.sort((a, b) => {
try {
if (article.pageType === PageType.File) {
Expand All @@ -286,6 +291,7 @@ export default class OmnivorePlugin extends Plugin {
return compareHighlightsInFile(a, b);
}
});
}
const highlights = articleHighlights.map((highlight) => {
return {
text: highlight.quote,
Expand All @@ -309,6 +315,9 @@ export default class OmnivorePlugin extends Plugin {
const datePublished = publishedAt
? formatDate(publishedAt, dateFormat)
: null;
const note = article.highlights?.find(
(h) => h.type === HighlightType.Note
);
// Build content string based on template
let content = Mustache.render(template, {
id: article.id,
Expand All @@ -331,6 +340,7 @@ export default class OmnivorePlugin extends Plugin {
? await this.downloadPDF(article)
: undefined,
description: article.description,
note,
});
const frontmatterRegex = /^(---[\s\S]*?---)/gm;
// get the frontmatter from the content
Expand Down

0 comments on commit ea65aa6

Please sign in to comment.