Docs
Routing
Page Data

Page Data

$page variable provides data of page.

Example:

Typescript
export const $page = {};

#$page.before/after

A function that is run before/after processing request.

Typescript
import { Context } from 'zely';
 
export function get(ctx: Context) {
  console.log('Doing something');
 
  return {};
}
 
export const $page = {
  before(ctx) {
    console.log('Hello');
  },
  after(ctx) {
    console.log('Bye');
  },
};

Console will print:

Plain
Hello
Doing something
Bye