1 Commits

Author SHA1 Message Date
olivier abf4d6ccf7 feat: configurable filter tags for recent files
New 'Filter tags' setting in Recent Files tab. Enter tag names one per line
to pin specific tags as filter pills. Leave empty to auto-detect from
frontmatter 'type' property (existing behavior).
2026-06-22 10:15:54 -04:00
6 changed files with 67 additions and 24 deletions
+17 -13
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"id": "waypoint-sidebar", "id": "waypoint-sidebar",
"name": "Waypoint Sidebar", "name": "Waypoint Sidebar",
"version": "1.4.1", "version": "1.5.0",
"minAppVersion": "0.16.3", "minAppVersion": "0.16.3",
"description": "Calendar, recent files, and custom bookmarks sidebar.", "description": "Calendar, recent files, and custom bookmarks sidebar.",
"author": "Olivier", "author": "Olivier",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "waypoint", "name": "waypoint",
"version": "1.4.1", "version": "1.5.0",
"description": "Calendar, recent files, and custom bookmarks sidebar.", "description": "Calendar, recent files, and custom bookmarks sidebar.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
+15
View File
@@ -220,6 +220,21 @@ export class WaypointSettingTab extends PluginSettingTab {
this.saveAndRefresh(); this.saveAndRefresh();
}; };
}); });
const filterDesc = new DocumentFragment();
filterDesc.appendText('Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property.');
new Setting(container)
.setName('Filter tags')
.setDesc(filterDesc)
.addTextArea((text) => {
text.inputEl.setAttr('rows', 4);
text.setPlaceholder('meeting\nperson\nproject');
text.setValue(this.settings.recentFiles.filterTags.join('\n'));
text.inputEl.onblur = () => {
this.settings.recentFiles.filterTags = text.getValue().split('\n').filter(t => t.trim());
this.saveAndRefresh();
};
});
} }
// ═══════════════════════════════ // ═══════════════════════════════
+2
View File
@@ -17,6 +17,7 @@ export interface RecentFilesSettings {
updateOn: 'file-open' | 'file-edit'; updateOn: 'file-open' | 'file-edit';
omittedPaths: string[]; omittedPaths: string[];
omittedTags: string[]; omittedTags: string[];
filterTags: string[]; // tags to show as filter pills (empty = auto-detect from frontmatter)
} }
export interface DisplaySettings { export interface DisplaySettings {
@@ -79,6 +80,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
updateOn: 'file-open', updateOn: 'file-open',
omittedPaths: [], omittedPaths: [],
omittedTags: [], omittedTags: [],
filterTags: [],
}, },
display: { display: {
rowSize: 26, rowSize: 26,
+31 -9
View File
@@ -241,14 +241,34 @@ export class WaypointView extends ItemView {
} }
// ── Type filter bar ── // ── Type filter bar ──
const typeCounts: Record<string, number> = {}; const configuredTags = this.plugin.settings.recentFiles.filterTags;
for (const file of this.plugin.recentFiles) { let typeCounts: Record<string, number> = {};
const tfile = this.app.vault.getAbstractFileByPath(file.path);
if (tfile instanceof TFile) { if (configuredTags.length > 0) {
const cache = this.app.metadataCache.getFileCache(tfile); // Use configured tags — count occurrences in recent files
const type = cache?.frontmatter?.type; for (const tag of configuredTags) {
if (type && typeof type === 'string') { typeCounts[tag] = 0;
typeCounts[type] = (typeCounts[type] || 0) + 1; }
for (const file of this.plugin.recentFiles) {
const tfile = this.app.vault.getAbstractFileByPath(file.path);
if (tfile instanceof TFile) {
const cache = this.app.metadataCache.getFileCache(tfile);
const type = cache?.frontmatter?.type;
if (type && typeof type === 'string' && typeCounts.hasOwnProperty(type)) {
typeCounts[type]++;
}
}
}
} else {
// Auto-detect from frontmatter `type` property
for (const file of this.plugin.recentFiles) {
const tfile = this.app.vault.getAbstractFileByPath(file.path);
if (tfile instanceof TFile) {
const cache = this.app.metadataCache.getFileCache(tfile);
const type = cache?.frontmatter?.type;
if (type && typeof type === 'string') {
typeCounts[type] = (typeCounts[type] || 0) + 1;
}
} }
} }
} }
@@ -262,7 +282,9 @@ export class WaypointView extends ItemView {
this.redraw(); this.redraw();
}); });
// Type pills // Type pills
const sortedTypes = Object.entries(typeCounts).sort(([,a], [,b]) => b - a); const sortedTypes = configuredTags.length > 0
? Object.entries(typeCounts) // preserve configured order
: Object.entries(typeCounts).sort(([,a], [,b]) => b - a); // sort by count
for (const [type, count] of sortedTypes) { for (const [type, count] of sortedTypes) {
const pill = filterBar.createSpan({ cls: `waypoint-recent-pill${this.recentFilesFilter === type ? ' is-active' : ''}` }); const pill = filterBar.createSpan({ cls: `waypoint-recent-pill${this.recentFilesFilter === type ? ' is-active' : ''}` });
pill.setText(`${type} ${count}`); pill.setText(`${type} ${count}`);