constexprjs executable requires three mandatory arguments, --input, --output, and --entry. --entry option can be used multiple times in an invocation. Its values must be paths of HTML files relative to the input root:
This is the sequence of operations constexprjs performs when it is invoked:
Render all the pages. For each page:
Figure out its dependencies (css, images, etc).
Snapshot the DOM state when the page finishes rendering.
Close the page.
Write the DOM snapshots of each page as HTML files.
Combine the dependency lists of all the pages into a single list.
Copy dependencies to the output directory.
It maintains a list of pages that it needs to process. In the beginning, this list contains only the pages specified as entry points (/index.html and /subsite/index.html in the above example). The constexpr code inside these entry points is supposed to use the addPaths api hook to notify the compiler about other pages that it needs to render. The argument of this function must be an object with two keys, generator and output:
These invocations will append /about.html and /posts/generator_from_date.html?2023-jan to the list of pages that the compiler needs to process. The compilation results of these pages will be written to /about.html and /posts/2023-jan.html respectively.
Think of the generator page as a function that takes input in url query string/hash and produces the intended page as output.
Every page except the entry points will have a parent page which queued it for compilation. The queueing relationship between the pages will form a tree:
Links to generated pages
The compiler also maps all the links to generator page (/posts/generator_from_date.html?2023-jan) to the correct output HTMLs (/posts/2023-jan.html). This ensures that the original and the final website look and work exactly the same even when you use this feature.