On this page
· 2 min read
Installation
This example is a best-practice @pagesmith/site + Vite + Handlebars static site: markdown collections validated at build time, SSR that returns HTML strings, and a thin browser entry for progressive enhancement. It does not use @pagesmith/docs; you own routing, templates, and layout.
How the pieces connect
-
content.config.mjs— Declares collections (guide,pages) with@pagesmith/siteZod schemas. This file is imported by the SSR entry so the same definitions drive validation and loading. The markdown showcase now lives atcontent/guide/kitchen-sink.md. -
createContentLayer— Insrc/entry-server.tsx, the entry builds a content layer from that config androot, then loads collections withgetCollection()and renders markdown withentry.render(). There are no virtualvirtual:content/*modules. -
SSR contract —
pagesmithSsgexpectsgetRoutes()andrender()exported from the entry module. You return a list of URL paths and a full HTML document per path. Handlebars compiles templates in that entry; nothing template-related ships to the client. -
Vite —
vite.config.tswiressharedAssetsPlugin()and...pagesmithSsg({ entry, contentDirs }). Dev middleware callsrender()for previews; production build walks routes and writes files, then runs Pagefind. -
Client —
client.jsimports site CSS and@pagesmith/site/runtime/contentfor small runtime behaviors on top of already-generated HTML (see Search integration for Pagefind UI). -
Agent notes — The example root includes
llms.txt(repository pathexamples/frameworks/with-vanilla-hbs/llms.txt) for a compact integration checklist. It is meant for tooling and clones, not linked from the generated site navigation.
Dependencies
{ "dependencies": { "@pagesmith/site": "*", "handlebars": "^4.7.9", "pagefind": "^1.5.0" }}Quick start
From the monorepo root:
git clone https://github.com/sujeet-pro/pagesmith.gitcd pagesmithvp installRun the dev server for this example:
vp run dev:eg:vanilla-hbsThat runs npm run dev in the workspace package (vite dev).
Production build from the repo root:
npm run build:eg:vanilla-hbsOr from examples/frameworks/with-vanilla-hbs/:
npm run buildOutput is written to gh-pages/examples/vanilla-hbs/ (see build.outDir in vite.config.ts).
What the Vite plugins do
-
pagesmithSsg— Invokes your SSR entry for route discovery and HTML generation, watchescontentDirsin dev, and runs Pagefind after a production build. -
sharedAssetsPlugin— Copies shared assets (for example fonts) from@pagesmith/siteinto the build output.
Guide order in the sidebar comes from each file’s frontmatter (series, seriesOrder, date), grouped in src/entry-server.tsx — not from a separate meta file.