feat: enhance Obsidian plugin with folder management features, including inclusion/exclusion settings and a status modal for real-time updates

This commit is contained in:
Anish Sarkar 2026-04-20 23:13:49 +05:30
parent 2251e464c7
commit 28d3c628f1
11 changed files with 267 additions and 154 deletions

View file

@ -64,3 +64,31 @@ export function parseExcludePatterns(raw: string): string[] {
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("#"));
}
/** Normalize a folder path: strip leading/trailing slashes; "" or "/" means vault root. */
export function normalizeFolder(folder: string): string {
return folder.replace(/^\/+|\/+$/g, "");
}
/** True if `path` lives inside `folder` (or `folder` is the vault root). */
export function isInFolder(path: string, folder: string): boolean {
const f = normalizeFolder(folder);
if (f === "") return true;
return path === f || path.startsWith(`${f}/`);
}
/** Exclude wins over include. Empty includeFolders means "include everything". */
export function isFolderFiltered(
path: string,
includeFolders: string[],
excludeFolders: string[],
): boolean {
for (const f of excludeFolders) {
if (isInFolder(path, f)) return true;
}
if (includeFolders.length === 0) return false;
for (const f of includeFolders) {
if (isInFolder(path, f)) return false;
}
return true;
}