mnaoumov_obsidian-advanced-.../demo-vault/_assets/CodeScriptToolkit/startup.ts
Michael Naumov 9daca194e8 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.
2026-07-20 14:12:05 -06:00

17 lines
804 B
TypeScript

// Per-vault startup script, run by the universal Demo Vault Helper plugin (via CodeScript
// 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';
// 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);
}
}