mirror of
https://github.com/mnaoumov/obsidian-smart-rename.git
synced 2026-07-22 07:40:32 +00:00
fix(demo-vault): export invoke() from startup script; add Invocables folder
CodeScript Toolkit runs the startup script via `startupScript.invoke(app)`, so a top-level script with no `invoke` export threw `this.startupScript.invoke is not a function` on vault open. Wrap the body in an exported `invoke(app)`. Also add an empty `Invocables/` folder so every demo vault has the same CodeScript Toolkit layout regardless of whether it ships invocable scripts.
This commit is contained in:
parent
1bd9782bd8
commit
494a720704
2 changed files with 10 additions and 3 deletions
0
demo-vault/_assets/CodeScriptToolkit/Invocables/.gitkeep
Normal file
0
demo-vault/_assets/CodeScriptToolkit/Invocables/.gitkeep
Normal file
|
|
@ -2,9 +2,16 @@
|
|||
// Toolkit's require) once CodeScript Toolkit is installed and enabled. This is where each
|
||||
// plugin's demo vault does its own startup setup. Here it just opens the landing note.
|
||||
|
||||
import type { App } from 'obsidian';
|
||||
|
||||
const START_NOTE_PATH = '00 Start.md';
|
||||
|
||||
const startNote = app.vault.getFileByPath(START_NOTE_PATH);
|
||||
if (startNote) {
|
||||
void app.workspace.getLeaf(false).openFile(startNote);
|
||||
// Run by CodeScript Toolkit on load (its `startupScriptPath` setting, which the Demo Vault Helper
|
||||
// points here). CST calls the exported `invoke` — a top-level script with no `invoke` export throws
|
||||
// `this.startupScript.invoke is not a function`.
|
||||
export async function invoke(app: App): Promise<void> {
|
||||
const startNote = app.vault.getFileByPath(START_NOTE_PATH);
|
||||
if (startNote) {
|
||||
await app.workspace.getLeaf(false).openFile(startNote);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue