MojoPad

Scripting: Event Pages

Event pages are plugins that run themselves. Name a page Event: Name and its script fires when that thing happens — the page is the handler.

Page nameFiresmojo.event contains
Event: Openwhen the document openstype
Event: Page Viewafter navigating to any pagetype, page
Event: Exportbefore any document exporttype, destination
Event: Publishbefore Static Publishing writes the sitetype, destination (the folder)
Event: Daily Notewhen a daily note is createdtype, page, date

Inside, the full mojo API is available, plus mojo.event with the details above. A tiny example — keep a visit log. Create Event: Page View containing:

if (!mojo.exists('Log')) await mojo.create('Log')
mojo.append('Log', mojo.today() + ' — ' + mojo.event.page)

Event scripts won't trigger themselves recursively, and errors flash in the status bar instead of interrupting you.