sercrod

Build environment (Node, Playwright, renderer)

This page explains how to run the official Sercrod renderer used for this site. It uses Node, Playwright (Chromium), and two small scripts: server.js and builder.js.

After the setup, you can:

Prerequisites

You will need:

The examples below assume:

You can adapt the paths to your own environment, as long as server.js and builder.js use the same layout.

Directory layout

A typical layout for the renderer is:

/home/sercrod.com/
  public_html/           # output: generated static HTML
  src/                   # sources and tools
    template.html        # layout template for all pages
    home.html            # partial: home page
    docs/                # partials for documentation
      index.html
      guide/
        first-page.html
        data-and-events.html
        ...
      reference/
        ssg-ssr.html
        config.html
        build-environment.html
    server.js            # build server (Node + Playwright)
    builder.js           # CLI front-end that calls the server

The renderer treats template.html as the layout and each partial (for example, home.html) as the source of per-page content and metadata.

Install Node dependencies

In the src directory, initialize a Node project and install the required packages:

cd /home/sercrod.com/src
npm init -y
npm install playwright js-beautify

This creates package.json and adds Playwright and js-beautify as dependencies.

Then install the Chromium binary for Playwright:

npx playwright install chromium

If you want to use other browsers, you can install them as well, but the official renderer uses Chromium.

server.js ? local build server

The build server is a Node script (for example server.js) that:

The full server.js implementation lives in the repository. Once placed under /home/sercrod.com/src, you can start it with:

cd /home/sercrod.com/src
node server.js

If it starts correctly, you should see a message such as:

server.js listening on http://0.0.0.0:1414/

builder.js ? CLI front-end

The builder is another Node script (for example builder.js) that sends a request to the local server and waits for the build result. It:

Once server.js is running, you can build a page by:

cd /home/sercrod.com/src
node builder.js /home.html

If the build succeeds, the command exits with status 0 and writes an HTML file under public_html using the same relative path. For example:

Building from the editor

Because builder.js is a simple CLI tool, you can call it from your editor or other automation whenever you save a file. The typical pattern is:

  1. Detect which HTML partial you just saved.
  2. Convert its filesystem path to the corresponding URL path.
  3. Run node builder.js <that-url-path>.

This keeps the build logic in one place (the server and builder) while letting you trigger SSG from any tool that can run a shell command.

Summary

With this setup, you can treat Sercrod as a small engine inside a static site generator, without adding a large framework or replacing your existing HTML.