Skip to content

Commit

Permalink
fix: download content and file attachment only if included in the tem…
Browse files Browse the repository at this point in the history
…plate
  • Loading branch information
sywhb committed May 30, 2023
1 parent 4c6df1e commit dc92a38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ export default class OmnivorePlugin extends Plugin {
manualSync && new Notice("🚀 Fetching articles ...");

// pre-parse template
preParseTemplate(template);
const templateSpans = preParseTemplate(template);
const includeContent = templateSpans.some(
(templateSpan) => templateSpan[1] === "content"
);
const includeFileAttachment = templateSpans.some(
(templateSpan) => templateSpan[1] === "fileAttachment"
);

const size = 50;
for (
Expand All @@ -211,7 +217,7 @@ export default class OmnivorePlugin extends Plugin {
size,
parseDateTime(syncAt).toISO(),
getQueryFromFilter(filter, customQuery),
true,
includeContent,
"highlightedMarkdown"
);

Expand All @@ -229,7 +235,7 @@ export default class OmnivorePlugin extends Plugin {
await this.app.vault.createFolder(folderName);
}
const fileAttachment =
article.pageType === PageType.File
article.pageType === PageType.File && includeFileAttachment
? await this.downloadFileAsAttachment(article)
: undefined;
const content = await renderArticleContnet(
Expand Down
2 changes: 1 addition & 1 deletion src/settings/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,5 @@ export const renderFolderName = (folder: string, folderDate: string) => {
};

export const preParseTemplate = (template: string) => {
Mustache.parse(template);
return Mustache.parse(template);
};

0 comments on commit dc92a38

Please sign in to comment.