Minimal static site generator with JSX to File rendering
npm install @papack/ssgMinimal static site generator with JSX to File rendering.
- Components can be async
- One-shot rendering (SSG -> static files)
- No state, no reactivity, no hydration
- Every route is just a function
``bash`
npm install @papack/ssg
`ts
import { StaticSiteGenerator } from "@papack/ssg";
const gen = new StaticSiteGenerator({
out: "./dist",
ctx: { siteName: "Example" },
});
gen.html("/", async (ctx) => {
return
await gen.run();
`
`ts`
gen.html("/", () =>
gen.html("/blog", () =>
gen.html("/about.html", () =>
Path mapping:
- / -> index.html/blog
- -> blog/index.html/about.html
- -> exact file
`ts`
gen.css("/style.css", () => "body {}");
gen.js("/app.js", () => "console.log('hi')");
- file extension required
- returns plain strings
- no bundling
`ts`
gen.public("/", "./public");
gen.file("/cv.pdf", "./cv.pdf");
`ts`
gen.notFound(() => 404
);
Generates 404.html.
`ts`
- single render function
- no keys, no diffing
- SSR-only
`ts`
Controls existence, not visibility.
)`ts``
new StaticSiteGenerator({
out: "./dist",
ctx: { api, version: "1.0" },
});