Skip to content

Expose public plugin API (refs #227)#324

Open
hauntedhost wants to merge 1 commit into
LostPaul:mainfrom
hauntedhost:expose-public-api
Open

Expose public plugin API (refs #227)#324
hauntedhost wants to merge 1 commit into
LostPaul:mainfrom
hauntedhost:expose-public-api

Conversation

@hauntedhost
Copy link
Copy Markdown

@hauntedhost hauntedhost commented Apr 25, 2026

Exposes a small public API on the plugin instance so external plugins (specifically supercharged_links) can resolve a folder path to its folder note without reaching into internals. Refs #227.

app.plugins.plugins['folder-notes']?.api?.getEnabledFolderNote(folderPath)
// returns TFile | null

Self-contained

  • All logic lives in a new src/api.ts
  • Zero changes to existing files apart from a 3-line wiring in main.ts (import, field, init in onload)

New api.getEnabledFolderNote function

  • Matches same logic the plugin UI uses for adding .has-folder-note
  • Returns null if:
    • the folder does not exist or has no folder note
    • the folder is detached
    • the folder is excluded with disableFolderNote

Adds a small public API surface on the plugin instance so external
plugins (specifically supercharged_links) can resolve a folder path
to its folder note without reaching into internals.

    app.plugins.plugins['folder-notes']?.api?.getEnabledFolderNote(path)
    // returns TFile | null

getEnabledFolderNote respects the same exclusion and detachment
semantics as the plugin's own UI: it returns null for folders that
wouldn't receive the .has-folder-note class. Consumers stay visually
consistent with folder-notes' own behavior.

The method name makes the gating explicit at the call site —
external plugin authors see "enabled" and know that exclusions/
detachment are honored without needing to read documentation.

Pattern mirrors the existing front-matter-title integration. No
new settings, no migrations, no behavior change for existing users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant