mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Add Exception helper class for consistent error handling and logging. Replace throw statements and console.error calls with Exception methods. Update service methods to return Error | T instead of mixed success/failure objects. Improve type safety in Claude.extractContents with explicit return type. Add WikiLinks helper to VaultCacheService for managing wiki link references. Update unit tests.
39 lines
No EOL
856 B
TypeScript
39 lines
No EOL
856 B
TypeScript
import { TFile } from "obsidian";
|
|
|
|
export class WikiLinks {
|
|
|
|
public links: string[] = [];
|
|
|
|
public addWikiLink(file: TFile) {
|
|
if (file.extension === "md") {
|
|
this.links.push(this.asWikiLink(file));
|
|
}
|
|
}
|
|
|
|
public removeWikiLink(file: TFile | string) {
|
|
if (file instanceof TFile) {
|
|
if (file.extension === "md") {
|
|
this.removeFromLinks(this.asWikiLink(file));
|
|
}
|
|
} else {
|
|
if (file.endsWith(".md")) {
|
|
this.removeFromLinks(this.asWikiLink(file));
|
|
}
|
|
}
|
|
}
|
|
|
|
private asWikiLink(file: TFile | string) {
|
|
if (file instanceof TFile) {
|
|
return file.path.replace(/\.md$/, "");
|
|
}
|
|
return file.replace(/\.md$/, "");
|
|
}
|
|
|
|
private removeFromLinks(wikiLink: string) {
|
|
const index = this.links.indexOf(wikiLink);
|
|
if (index !== -1) {
|
|
this.links.splice(index, 1);
|
|
}
|
|
}
|
|
|
|
} |