Building a plugin.
A plugin exports one function per hook. Inside those functions it uses the fs object to log, fetch, read and write data, or schedule work. This page is the shape of the code, the tools around it, and the rules the sandbox enforces.
The shape of the code
Export a handler for each hook the plugin declares. A handler takes the hook input and returns the value the pipeline expects (see Hooks).
module.exports = {
pre_render: async (input) => {
// read the site's three newest events and expose them to the template
const res = await fs.collection('events').list({ limit: 3, order: 'inserted_at desc' })
return { upcoming_events: res.items }
},
post_render: (input) => {
// add a banner to the finished page
return input.html.replace('