Skip to content

Commit 1b803f8

Browse files
committed
fix: tag-based search (#198)
1 parent 8ff9d29 commit 1b803f8

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

scripts/bookmark-or-recent-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function run(argv) {
112112

113113
const subtitle =
114114
subtitleType === "parent"
115-
? parentFolder(relativePath)
115+
? "▸ " + parentFolder(relativePath)
116116
: (file.tags || []).map((/** @type {string} */ t) => "#" + t).join(" ");
117117

118118
// push result

scripts/o_search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function run() {
204204

205205
const subtitle =
206206
subtitleType === "parent"
207-
? parentFolder(relativePath)
207+
? "▸ " + parentFolder(relativePath)
208208
: (file.tags || []).map((/** @type {string} */ t) => "#" + t).join(" ");
209209

210210
// Notes (file names)

scripts/search-files-with-tag.js

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function run() {
3030
const metadataJSON = `${vaultPath}/${configFolder}/plugins/metadata-extractor/metadata.json`;
3131
const starredJSON = `${vaultPath}/${configFolder}/starred.json`;
3232
const bookmarkJSON = `${vaultPath}/${configFolder}/bookmarks.json`;
33-
const superIconFile = $.getenv("supercharged_icon_file");
33+
const subtitleType = $.getenv("main_search_subtitle");
3434

3535
let recentJSON = `${vaultPath}/${configFolder}/workspace.json`;
3636
if (!fileExists(recentJSON)) recentJSON = recentJSON.slice(0, -5); // Obsidian 0.16 uses workspace.json → https://discord.com/channels/686053708261228577/716028884885307432/1013906018578743478
@@ -66,14 +66,6 @@ function run() {
6666

6767
//───────────────────────────────────────────────────────────────────────────
6868

69-
let superIconList = [];
70-
if (superIconFile && fileExists(superIconFile)) {
71-
superIconList = readFile(superIconFile)
72-
.split("\n")
73-
.filter((l) => l.length !== 0);
74-
}
75-
console.log("superIconList length: " + superIconList.length);
76-
7769
const jsonArray = [];
7870

7971
//──────────────────────────────────────────────────────────────────────────────
@@ -123,31 +115,16 @@ function run() {
123115
if ($.getenv("remove_emojis") === "1") emoji = "";
124116
if (filename.toLowerCase().includes("kanban")) iconpath = "icons/kanban.png";
125117

126-
let superchargedIcon = "";
127-
let superchargedIcon2 = "";
128-
if (superIconList.length > 0 && file.tags) {
129-
superIconList.forEach((pair) => {
130-
const tag = pair.split(",")[0].toLowerCase().replaceAll("#", "");
131-
const icon = pair.split(",")[1];
132-
const icon2 = pair.split(",")[2];
133-
if (file.tags.includes(tag) && icon) superchargedIcon = icon + " ";
134-
else if (file.tags.includes(tag) && icon2) superchargedIcon2 = " " + icon2;
135-
});
136-
}
137-
138-
// exclude cssclass: private
139-
let displayName = filename;
140-
const censorChar = $.getenv("censor_char");
141-
const isPrivateNote = file.frontmatter?.cssclass?.includes("private");
142-
const privacyModeOn = $.getenv("privacy_mode") === "1";
143-
const applyCensoring = isPrivateNote && privacyModeOn;
144-
if (applyCensoring) displayName = filename.replace(/./g, censorChar);
118+
const subtitle =
119+
subtitleType === "parent"
120+
? "▸ " + parentFolder(relativePath)
121+
: (file.tags || []).map((/** @type {string} */ t) => "#" + t).join(" ");
145122

146123
// push result
147124
jsonArray.push({
148-
title: emoji + superchargedIcon + displayName + superchargedIcon2,
125+
title: emoji + filename,
149126
match: additionalMatcher + alfredMatcher(filename),
150-
subtitle: "▸ " + parentFolder(relativePath),
127+
subtitle: subtitle,
151128
arg: relativePath,
152129
quicklookurl: vaultPath + "/" + relativePath,
153130
type: "file:skipcheck",

0 commit comments

Comments
 (0)