Skip to content

Commit

Permalink
fix: add labels of highlights to the template
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Mar 31, 2023
1 parent 43a3966 commit 4b8aee1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TFile,
TFolder,
} from "obsidian";
import { FolderSuggest } from "./settings/file-suggest";
import {
Article,
compareHighlightsInFile,
Expand All @@ -23,7 +24,6 @@ import {
parseDateTime,
replaceIllegalChars,
} from "./util";
import { FolderSuggest } from "./settings/file-suggest";

enum Filter {
ALL = "import all my articles",
Expand Down Expand Up @@ -255,6 +255,9 @@ export default class OmnivorePlugin extends Plugin {
this.settings.dateHighlightedFormat
),
note: highlight.annotation,
labels: highlight.labels?.map((l) => ({
name: l.name,
})),
};
});
const dateFormat = this.settings.dateSavedFormat;
Expand Down Expand Up @@ -515,7 +518,7 @@ class OmnivoreSettingTab extends PluginSettingTab {
href: "https://github.com/janl/mustache.js/#templates",
}),
fragment.createEl("p", {
text: "Available variables: id, title, omnivoreUrl, siteName, originalUrl, author, content, dateSaved, labels.name, highlights.text, highlights.highlightUrl, highlights.note, highlights.dateHighlighted",
text: "Available variables: id, title, omnivoreUrl, siteName, originalUrl, author, content, dateSaved, labels.name, highlights.text, highlights.highlightUrl, highlights.note, highlights.dateHighlighted, highlights.labels.name",
}),
fragment.createEl("p", {
text: "Please note that id in the frontmatter is required for the plugin to work properly.",
Expand Down
13 changes: 7 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface Highlight {
annotation: string;
patch: string;
updatedAt: string;
labels?: Label[];
}

export interface HighlightPoint {
Expand Down Expand Up @@ -111,12 +112,12 @@ export const loadArticle = async (
export const loadArticles = async (
endpoint: string,
apiKey: string,
after: number = 0,
first: number = 10,
updatedAt: string = "",
query: string = "",
includeContent: boolean = false,
format: string = "html"
after = 0,
first = 10,
updatedAt = "",
query = "",
includeContent = false,
format = "html"
): Promise<[Article[], boolean]> => {
const res = await requestUrl({
url: endpoint,
Expand Down

0 comments on commit 4b8aee1

Please sign in to comment.