SSE | Sygnal Site Engine
Community ForumSupport Us!Micro-Consulting
  • Sygnal Site Engine ( SSE )
  • The SSE Architecture
  • What's New
  • Feature Roadmap
    • Component Architecture
    • File Copy & Augmented Builds
    • SA5 Integration
  • Installation & Setup
    • Setup Github Repository
    • Setup Netlify
      • jsDelivr
    • Setup Webflow
    • Advanced Install Notes
      • Creating a Persistent Test Env
      • Add SSE to an Existing Repo
  • Usage Notes
    • Developing with SSE
    • Building & Deploying Code
    • Code Structure
    • Page Router
    • Components
      • Components Future Notes
    • Source Structure & Key Files
      • Utilities
      • Route Dispatcher
      • Infrastructure
      • Usage Notes
    • SCSS
    • Useful Library Additions
      • Adding Libraries
      • Luxon
      • Cookies
      • Core Libraries
      • Extending Capabilities
    • Best Practices
    • Unit Testing
      • Using Google Sheets as a Unit Test Data Source
      • Datetime & Timezone Tests
      • Best Practices
      • Page 1
  • Sygnal Devproxy
    • What is Devproxy?
    • Devproxy Setup
    • Cloudflare Setup
    • Webflow Site Configuration
    • Configurations
      • Controlling deployment flow
    • Future
  • Tech Stack
    • Source Code Repository
    • Visual Studio Code
    • Developer IDE
    • Dev Hosting
    • Code CDN
    • Devproxy
  • Further Development
    • Dev Team Notes
      • Engine Mode
    • Reference Project
    • Future
      • Component Development
      • Reactive State Management
      • Expand Script Loading
    • Devmode
    • CI/CD Discussions
      • Page 2
    • SA5
  • Tools
    • Webflow Designer Notation
  • SPECIAL ENHANCEMENTS
    • cookie.js
    • PostHog
Powered by GitBook
On this page
  • Usage Notes
  • How this Works
  1. Usage Notes

Page Router

PreviousCode StructureNextComponents

Last updated 4 months ago

The Page Router handles page-specific code execution, and is defined in routes.ts.

Usage Notes

  • First, and give it a unique page class name like ContactPage.

  • Then reference that class in the Page Router below

In this example;

  • We have a home page with code, and we also have a blog page with code, so we've created two Page classes, HomePage and BlogPage.

  • Home page is, of course, at a predefined path /.

  • The Blog is a CMS collection with the Blog pages under /blog/. To represent this, we use a * wildcard for the matching.

import { RouteDispatcher } from "@sygnal/sse";
import { Site } from "./site";
import { HomePage } from "./page/home";
import { BlogPage } from "./page/blog";

export const routeDispatcher = (): RouteDispatcher => {
    
    var routeDispatcher = new RouteDispatcher(Site);
    routeDispatcher.routes = {

        // Site pages
        '/': HomePage,
        '/blog/*': BlogPage, 

    };

    return routeDispatcher;
}

How this Works

  • Site code will be executed first.

  • A visit to the home page at / will execute the code in our HomePage class.

  • A visit to any blog page, e.g. /blog/2024-in-review or /blog/ai-futures-2025 will match our /blog/* route and execute the code in our BlogPage class.

  • A visit to any other page, such as /about will execute nothing, because there is no route defined for it.

  • A visit to /blog by itself, which might be a blog directory page, will execute nothing, because it does not match any patterns.

    • If you wanted /blog to also execute your BlogPage code, you could simply add another route for '/blog`: BlogPage .

  • Each route can execute only one Page class.

  • Each route must be unique, but you can add as many routes as you like.

create your Page class