Enable Features
Webstir supports an enable workflow to opt into optional functionality by writing the required scaffold files and turning on the corresponding package.json flags.
Usage
webstir enable <feature>
webstir enable scripts <page>
Supported features:
scripts <page>— addindex.tsto an existing pagespa— opt into SPA routingclient-nav— enable client-side navigation (feature module)search— enable site search UI + behavior (feature modules + CSS)content-nav— enable docs content navigation (sidebar, breadcrumb, h2 TOC)backend— add backend scaffold and switch towebstir.mode=fullgithub-pages [basePath]— scaffold a Bun-based GitHub Pages deploy script and set the publish base pathgh-deploy [basePath]—github-pagesplus a GitHub Actions workflow
What enable Changes
scripts <page>
- Adds
src/frontend/pages/<page>/index.ts. - Fails if the page does not exist or already has
index.ts.
spa
- Writes SPA/router scaffold under
src/frontend/app/**. - Updates
package.json:webstir.enable.spa=true
client-nav
- Writes
src/frontend/app/scripts/features/client-nav.ts. - Appends a side-effect import to
src/frontend/app/app.ts:import "./scripts/features/client-nav.js";
- Updates
package.json:webstir.enable.clientNav=true
search
- Writes:
src/frontend/app/scripts/features/search.tssrc/frontend/app/styles/features/search.css
- Appends imports:
src/frontend/app/app.ts:import "./scripts/features/search.js";src/frontend/app/app.css: adds thefeatureslayer (if missing) and imports./styles/features/search.css
- Enables CSS-style search mode by adding an attribute to
src/frontend/app/app.html:<html data-webstir-search-styles="css">
- Updates
package.json:webstir.enable.search=true
content-nav
- Writes:
src/frontend/app/scripts/features/content-nav.tssrc/frontend/app/styles/features/content-nav.css
- Appends imports:
src/frontend/app/app.ts:import "./scripts/features/content-nav.js";src/frontend/app/app.css:@import "./styles/features/content-nav.css";
- Updates
package.json:webstir.enable.contentNav=trueApplies to SSG docs pages (content pipeline) only.
backend
- Creates
src/backend/**if missing (using the current backend package scaffold). - Updates
package.json:webstir.mode=fullwebstir.enable.backend=true
- Ensures
base.tsconfig.jsonincludes areferencesentry forsrc/backend.
github-pages
- Writes
utils/deploy-gh-pages.sh. - Updates
src/frontend/frontend.config.json:publish.basePath="/<workspace-name>"by default, or the path you pass
- Updates
package.json:webstir.enable.githubPages=true- adds
scripts.deploy="bash ./utils/deploy-gh-pages.sh"if missing
gh-deploy
- Applies all
github-pageschanges. - Also writes
.github/workflows/webstir-gh-pages.ymlif it does not already exist. - The generated workflow is Bun-based and runs
bun installplusbun run deploy.
Notes
enableis additive and idempotent: it avoids duplicating imports on re-run.- Feature scripts are appended as
.jsimports inapp.tsbecause the dev server serves the compiled output underbuild/frontend/**.